Commit 35376075 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

vbscript: Support non-Latin 1 characters in Asc.

parent 3d31e52f
...@@ -1749,10 +1749,27 @@ static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA ...@@ -1749,10 +1749,27 @@ static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA
str = conv_str; str = conv_str;
} }
if(!SysStringLen(str) || *str >= 0x100) if(!SysStringLen(str))
hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL); hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL);
else if(res) else {
hres = return_short(res, *str); 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); SysFreeString(conv_str);
return hres; return hres;
} }
......
...@@ -1842,6 +1842,11 @@ call testAsc(" ", 32) ...@@ -1842,6 +1842,11 @@ call testAsc(" ", 32)
call testAsc(Chr(255), 255) call testAsc(Chr(255), 255)
call testAsc(Chr(0), 0) call testAsc(Chr(0), 0)
if isEnglishLang then testAsc true, 84 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() call testAscError()
sub testErrNumber(n) sub testErrNumber(n)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment