SpiderMonkey是否正确地处理Unicode转义?当我尝试打印一个用unicode转义到标准的SpiderMonkey字符串时,它会咀嚼它们。V8和Node.JS显示了预期的输出。
这里是SpiderMonkey:
$ js
js> this.print("\u201cquotes\u201d")
quotes这比看起来更糟,因为输出包含无效的UTF-8的二进制数据。
下面是V8,它显示了引号:
$ v8
V8 version 3.7.0 [sample shell]
> this.print("\u201cquotes\u201d")
“quotes”下面是Node.JS,它还显示了引号:
$ node
> console.log("\u201cquotes\u201d")
“quotes”编辑:我在MacOSX10.8.2(山狮)上运行。
$ echo $LANG
en_US.UTF-8
$ js --version
JavaScript-C 1.8.5 2011-03-31
$ brew info spidermonkey
spidermonkey: stable 1.8.5, HEAD
https://developer.mozilla.org/en/SpiderMonkey
Depends on: readline, nspr
/usr/local/Cellar/spidermonkey/1.8.5 (101 files, 12M) *
https://github.com/mxcl/homebrew/commits/master/Library/Formula/spidermonkey.rb
==> Caveats
This formula installs Spidermonkey 1.8.5.
If you are trying to compile MongoDB from scratch, you will need 1.7.x instead.发布于 2013-01-19 05:19:52
你在执行哪一次修订?在我的机器上查看mozilla中央,它看起来是对的。
mozilla-central/js/dbg$ echo $LANG
en_US.UTF-8
mozilla-central/js/dbg$ ./js -e 'this.print("\u201cquotes\u201d")'
“quotes”
mozilla-central/js/dbg$ hg log -l1 | head -n1
changeset: 119130:8cc32d6fa707https://stackoverflow.com/questions/14370695
复制相似问题