On Wed, 29 Oct 2014 17:57:15 +0800, Shuai Meng wrote:
> I have tested this for many times, but it is very strange that the result
> of String(1, 564) varies with different platforms, running in cmd on xp,
> it equals to String(1, 564 / 256) while equals to String(1, 564 mod 256)
> running directly in vbs script(meaning save vbs code as test.vbs and double
> click it).
> That confuses me a lot, according to MSDN documents, it should equal to
> String(1, 564 mod 256), I don't know how to handle it.
Hello Shuai,
Despite MSDN documents, VBScript String function accepts double-byte
character code in DBCS locale based on my tests. That means you can
specify like String(3, &HE0E0) where &HE0E0 is an ANSI codepage
character code not a Unicode codepoint.
I guess String(1, 564) is internally interpreted as "\x02\x34" in DBCS
locale. As you know, \x02 isn't a valid lead-byte character, so, you got
"\x02". On the other hand, in SBCS locale, VBScript engine did 564 mod
256, thus, Piotr got "4".
Regards,
Akihiro Sagawa