Javascript 特殊字符返回错误
有一个页面上有某些特殊字符,当通过 javascript 检索这些特殊字符的值时,我得到了一个奇怪的转换。字符“Œ”将以“R”的形式回归,其小写版本“œ”将以“S”的形式回归。这是 javascript 的限制还是可能是浏览器的限制。这是在 Firefox 中测试的结果。此外,这是通过 repl 客户端 (Jssh/MozRepl) 检索的,因此看来这可能是这些客户端本身而不是浏览器的问题。
There is a page where I have certain special characters on and when retrieving values of these via javascript I am getting an odd conversion. The character 'Œ' is coming back as 'R' and its lower case version 'œ' is coming back as 'S'. Is this a limitation of javascript or could it possibly be the browser. This is from testing in firefox. Also this is being retrieved via a repl client (Jssh/MozRepl) so it seems that it could be an issue with these clients themselves rather than the browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能在某个地方遇到编码问题。有很多机会错误地处理文本编码。如果您发布一些代码,我们也许可以帮助您找到它。
You likely have an encoding problem somewhere. There are many opportunities to mis-handle the encoding of text. If you post some code, we might be able to help you find it.
输出流对于非 ASCII 字符来说不安全,因此您需要将流包装在 nsIBinaryOutputStream、nsIUnicharOutputStream 或 nsIConverterOutputStream 中。
Output streams aren't scriptably safe for non-ASCII characters so you will need to wrap the stream in a nsIBinaryOutputStream, a nsIUnicharOutputStream or a nsIConverterOutputStream.