Java 用于编码 ASCII 的不可映射字符,但我的文件是 UTF-8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26067350/
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
Unmappable character for encoding ASCII but my files are in UTF-8
提问by Jerome Ansia
I have the following error launching my ant script:
启动我的 ant 脚本时出现以下错误:
[javac] /****/TextUtils.java:25: error: unmappable character for encoding ASCII
But this file is encoded in UTF-8, if i do the info command:
但是这个文件是用 UTF-8 编码的,如果我执行 info 命令:
/***/TextUtils.java: text/plain; charset=utf-8
Why is this file compiled in ASCII and not in utf-8?
为什么这个文件是用 ASCII 而不是 utf-8 编译的?
I tried to force the encoding in utf-8 on the javac command in my ant build file but without success
我试图在我的 ant 构建文件中的 javac 命令上强制使用 utf-8 编码,但没有成功
采纳答案by Alexey Semenyuk
Setting the Default Java File Encoding to UTF-8:
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
将默认 Java 文件编码设置为 UTF-8:
导出 JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8