如何在 Windows 中更改默认系统 java 编码形式?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9661935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the defaults system java encode form in windows?
提问by user1232236
When I tried to compile (use javac)some java sources files include a comment line which has some unrecognized char like ascii code 129 (~A), error got.
当我尝试编译(使用 javac)某些 Java 源文件包含注释行时,该注释行包含一些无法识别的字符,例如 ascii 代码 129 (~A),出现错误。
The sources code looks like the following:
源代码如下所示:
// ascii 129 is ? (Acutally it show ~A in VIM but show ? when I directly copy it here)
The above code line is a comment, it should not cause any error, but if it did, I think it should be a problem about the jave encode form, how can I solve this problem?
上面的代码行是注释,应该不会引起任何错误,但是如果发生了,我认为应该是jave编码形式的问题,我该如何解决这个问题?
Thanks.
谢谢。
Wa
佤
采纳答案by kentcdodds
Take a look at this answer. It worked for me, and I don't have to worry about it anymore :) https://stackoverflow.com/a/623036/971592
看看这个答案。它对我有用,我不必再担心了:) https://stackoverflow.com/a/623036/971592
回答by Joop Eggen
Pick the correct encoding of the java source. UTF-8 would be a good requirements standard. One can use the open source editor JEdit to test which encoding the source actually is in. The java tool native2asciican convert.
选择 Java 源代码的正确编码。UTF-8 将是一个很好的要求标准。可以使用开源编辑器JEdit来测试源码实际是哪种编码。java工具native2ascii可以转换。
javac -encoding UTF-8 ...