最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why does chr(199) appear to return the wrong value in VBScript? - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

3 Answers 3

Reset to default 8

Edited to reflect ments

Chr(199) returns a 2-byte character, which is being interpreted as 2 separate characters.

  • use ChrW(199) to return a Unicode 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.

发布评论

评论列表(0)

  1. 暂无评论