[PATCH] vbscript: Implemented Asc(try 4)

Shuai Meng mengshuaicalendr at gmail.com
Thu Mar 12 07:37:05 CDT 2015


Hi,
I meet some problems when I write tests for ChrW, here are the tests:

1327 Call ok(ChrW(126) = "~", "ChrW(126) = " & ChrW(126))
1328 Call ok(AscW("~") = 126, "AscW(""A"") = " & AscW("A"))
1329 Call ok(ChrW(194) = "Â", "ChrW(194) = " & ChrW(194))
1330 Call ok(AscW("Â") = 194, "AscW(""Â"") = " & AscW("Â"))

and the results on testbot are:

run.c:1116: Test failed: api.vbs: L"ChrW(194) = \00c2"
run.c:1116: Test failed: api.vbs: L"AscW(\"\00c3\201a\") = 195"


On my Ubuntu system, UTF-8 is used as the default encoding. The
unicode number for "Â" is 0xc2, so the number is stored in utf-8 form
as 0xc3201a with two bytes. However, vbscript use utf-16 as the
default encoding, so 0xc3201a is interpreted as two independent
characters whose unicode number are 0xc3 and 0x201a. AscW takes the
first character and returns its unicode number 195.


My problem is, I can't figure out a way to write test codes with
encoding utf-16, so the tests always fails on windows.


Thanks.


2015-03-06 12:39 GMT+08:00 Shuai Meng <mengshuaicalendr at gmail.com>:

> Thanks for commenting.
>
> 2015-03-06 0:49 GMT+08:00 Piotr Caban <piotr.caban at gmail.com>:
>
>> On 03/04/15 19:59, Shuai Meng wrote:
>>
>>> Change log:
>>>    Free 'bstr' only when it comes from to_string().
>>> ---
>>>   dlls/vbscript/global.c      | 26 ++++++++++++++++++++++++--
>>>   dlls/vbscript/tests/api.vbs | 42
>>> ++++++++++++++++++++++++++++++++++++++++++
>>>   2 files changed, 66 insertions(+), 2 deletions(-)
>>>
>> This function needs to convert the WCHAR to correct character set. In
>> order to easily write a test for it ChrW needs to be implemented first.
>>
>> The test may e.g. look like this:
>> Asc(ChrW(261))
>> Your implementation will return 261 in this case, on windows it produces
>> 97.
>
> I will try to implement ChrW.
>
>>
>> Cheers,
>> Piotr
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20150312/c1a29d28/attachment.html>


More information about the wine-devel mailing list