蜘蛛猴壳。如何更改源代码的编码?
如果我输入
print("®".length)
smjs
,它会打印 2。如果我在我的 Firefox 和 Opera 中输入 javascript:alert("®".length)
,它会打印 1。Rhino也打印 1。 是否可以告诉 smjs 我想将这些字符视为单个字符?操作系统:linux(Ubuntu 9.04),区域设置:UTF-8。
If I enter
print("®".length)
in smjs
, it prints 2. If I enter javascript:alert("®".length)
in my firefox as well as opera, it prints 1. Rhino prints 1 too.
Is it possible to tell smjs that I want to treat such characters as single character? Os: linux(Ubuntu 9.04), locale: UTF-8.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JS shell(也许不幸的是:-)不支持区域设置。看起来这个问题已被 Bug 648102 修复——所有输入行shell 被解码为 UTF-8。耶进步了!
我在 Firefox 精美的新 JS 暂存器中得到了相同的结果,这证实了您最初的基于
javascript:
的结果!The JS shell is (maybe unfortunately :-) not locale-aware. It looks like this problem has been fixed by Bug 648102 -- all input lines in the shell are decoded as UTF-8. Yay progress!
And I get the same result in Firefox's fancy new JS scratchpad, which confirms your original
javascript:
-based result!