我的操作系统是带有希伯来语语言环境的Windows 7,并在我的代码中使用Java 6。 我已将我的语言环境更改为英语(美国),并将显示语言更改为英语。 我重新启动了我的电脑,然后在我的java代码中尝试获取默认字符集,如下所示:
String str = Charset.defaultCharset().name();结果,str设置为windows-1255 。 这意味着它仍然使用希伯来语作为默认字符集。 什么似乎是问题?
My OS is windows 7 with Hebrew locale and using Java 6 in my code. I've changed my locale to English(United States) and also the display language to English. I restarted my PC and then in my java code tried to get the default charset as follow:
String str = Charset.defaultCharset().name();The result, str is set to windows-1255. Which means that it still using the Hebrew as the default charset. What seems to be the problem?
最满意答案
通过OpenJDK源代码, file.encoding和defaultCharset()在Windows上根据以下内容设置:
Java 6: GetUserDefaultLCID API函数,它对应于“区域和语言”控制面板小程序的“格式”选项卡上的“格式”选项。
Java 7: GetSystemDefaultLCID API函数,对应于“区域和语言”控制面板小程序的“管理”选项卡上的“非Unicode程序的语言”,除非您将sun.locale.formatasdefault Java系统属性设置为true ,这将恢复为Java 6的行为。
因此,对于Java 6,Format是要更改的设置。
Going by OpenJDK sources, file.encoding and thus defaultCharset() is set on Windows according to:
Java 6: GetUserDefaultLCID API function which corresponds to the Format option on the Formats tab of the Region and Language control panel applet.
Java 7: GetSystemDefaultLCID API function which corresponds to the "Language for non-Unicode programs" on the Administrative tab of the Region and Language control panel applet, unless you set the sun.locale.formatasdefault Java system property to true, which will revert to the Java 6 behavior.
So for Java 6 the Format is the setting to change.
更多推荐
语言,str,java,Hebrew,code,电脑培训,计算机培训,IT培训"/> <meta name="descr
发布评论