[PATCH] vbscript: Support non-Latin 1 characters in Asc.
Akihiro Sagawa
sagawa.aki at gmail.com
Wed Sep 16 07:19:03 CDT 2020
On Tue, 15 Sep 2020 14:18:45 +0200, Jacek Caban wrote:
> Hi Akihiro,
Hi Jacek,
> On 12.09.2020 09:38, Akihiro Sagawa wrote:
[...]
> > + unsigned char buf[2];
> > + short val = 0;
> > + int n = WideCharToMultiByte(CP_ACP, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL);
>
> I think we should use WC_ERR_INVALID_CHARS here.
I don't think so. WC_ERR_INVALID_CHARS is only applicable to CP_UTF8.
Nowhere, WC_ERR_INVALID_CHARS is used with CP_ACP.
[...]
> > + default:
> > + WARN("Failed to convert %x\n", *str);
> > + hres = E_FAIL;
>
> I think it should be MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL).
Will do.
> > + }
> > + if(res && SUCCEEDED(hres))
> > + hres = return_short(res, val);
>
> return_short already takes care of NULL res, there is no need to check
> it here.
Indeed, will do.
> Also, 2-byte variant may overflow short int and your patch
> will represent them as negative VT_I2. Maybe that's what native does, but it
> seems like using VT_I4 in such case could be appropriate. Did you
> verify that with Windows?
Good point. I verified that it may negative on native. For instance,
Asc(Chr(&h8e8e)) returns -29042, not 36494, on Japanese Windows.
I'll add some conformance tests regarding this case and submit v2 patch.
Thanks for reviewing,
Akihiro Sagawa
More information about the wine-devel
mailing list