vbscript: Support non-Latin 1 characters in Asc.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49309 Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3d31e52fe7
commit
35376075ac
|
@ -1749,10 +1749,27 @@ static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA
|
|||
str = conv_str;
|
||||
}
|
||||
|
||||
if(!SysStringLen(str) || *str >= 0x100)
|
||||
if(!SysStringLen(str))
|
||||
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
||||
else if(res)
|
||||
hres = return_short(res, *str);
|
||||
else {
|
||||
unsigned char buf[2];
|
||||
short val = 0;
|
||||
int n = WideCharToMultiByte(CP_ACP, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL);
|
||||
switch(n) {
|
||||
case 1:
|
||||
val = buf[0];
|
||||
break;
|
||||
case 2:
|
||||
val = (buf[0] << 8) | buf[1];
|
||||
break;
|
||||
default:
|
||||
WARN("Failed to convert %x\n", *str);
|
||||
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
|
||||
}
|
||||
if(SUCCEEDED(hres))
|
||||
hres = return_short(res, val);
|
||||
}
|
||||
|
||||
SysFreeString(conv_str);
|
||||
return hres;
|
||||
}
|
||||
|
|
|
@ -1842,6 +1842,11 @@ call testAsc(" ", 32)
|
|||
call testAsc(Chr(255), 255)
|
||||
call testAsc(Chr(0), 0)
|
||||
if isEnglishLang then testAsc true, 84
|
||||
if Asc(Chr(&h81)) = &h8145 then
|
||||
' Japanese (CP 932)
|
||||
call testAsc(Chr(&h8e8e), -29042)
|
||||
call testAsc(Chr(220), 220)
|
||||
end if
|
||||
call testAscError()
|
||||
|
||||
sub testErrNumber(n)
|
||||
|
|
Loading…
Reference in New Issue