简体   繁体   English

为Javascript指定字符编码

[英]Specifying a Character Encoding for Javascript

I am trying to convert a string into uppercase using a specific character encoding, but it fails. 我试图使用特定的字符编码将字符串转换为大写,但它失败了。

When I convert istanbul, it converts it into ISTANBUL. 当我转换伊斯坦布尔时,它将其转换为伊斯坦布尔。 However, uppercase "i" is "İ" in Turkish. 但是,土耳其语中的大写“i”是“İ”。 Is there any solution to this? 这有什么解决方案吗?

Demo: http://jsfiddle.net/fgZZp/ 演示: http//jsfiddle.net/fgZZp/

Thanks in advance, 提前致谢,

To some degree - the JavaScript String class does have a toLocaleUpperCase method, but the locale used is always the user's locale. 在某种程度上--JavaScript String类具有toLocaleUpperCase方法,但使用的语言环境始终是用户的语言环境。 You can't arbitrarily choose a locale for it to use. 您不能随意选择要使用的区域设置。

(Nitpick: What you're asking about is a locale issue, not character encoding. Character encoding only has to do with what bits are used to represent a given character; it doesn't generally affect how operations on those characters should behave.) (Nitpick:你所问的是一个语言环境问题,而不是字符编码。字符编码只与用于表示给定字符的比特有关;它通常不会影响对这些字符的操作应该如何表现。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM