I'm trying to convert a character code to a character with chr(), but VBScript isn't giving me the value I expect. According to VBScript, character code 199 is:
�
However, when using something like Javascript's String.fromCharCode, 199 is:
Ç
The second result is what I need to get out of VBScript's chr() function. Any idea what the problem is?
I'm trying to convert a character code to a character with chr(), but VBScript isn't giving me the value I expect. According to VBScript, character code 199 is:
�
However, when using something like Javascript's String.fromCharCode, 199 is:
Ç
The second result is what I need to get out of VBScript's chr() function. Any idea what the problem is?
Share Improve this question edited Nov 20, 2024 at 14:26 TylerH 21.1k78 gold badges79 silver badges113 bronze badges asked Nov 24, 2008 at 22:23 David BrownDavid Brown 36.3k12 gold badges89 silver badges139 bronze badges3 Answers
Reset to default 8Edited to reflect ments
Chr(199)
returns a 2-byte character, which is being interpreted as 2 separate characters.
- use
ChrW(199)
to return aUnicode
string. - use
ChrB(199)
to return it as a single-byte character
Encoding is the problem. Javascript may be interpreting as latin-1; VBScript may be using a different encoding and getting confused.
The fromCharCode()
takes the specified Unicode
values and returns a string.
The Chr()
function converts the specified ANSI
character code to a character.