简体   繁体   English

有关编码UTF-8的不可映射字符的编译错误

[英]compilation error regarding unmappable character for encoding UTF-8

  //  Fahrenheit (°F)

I have the above code commented out in my java code, but I get the "unmappable character for encoding UTF-8". 我在我的java代码中注释了上面的代码,但是我得到了“用于编码UTF-8的不可映射的字符”。 How do I fix this? 我该如何解决?

You need to specify the encoding in your javac command line using the -encoding flag 您需要使用-encoding标志在javac命令行中指定编码

javac -encoding UTF-8 myclass.java

You can also look into making UTF-8 your system default encoding so you don't have to specify it. 您还可以考虑将UTF-8作为系统默认编码,这样您就不必指定它。

Having this same compiler error with a ton of java files in the ISO-8859-1. 与ISO-8859-1中的大量java文件具有相同的编译器错误。 Opening one by one is impracticable. 一个接一个地打开是不切实际的。 So, here's a quick fix ( using recode ): 所以,这是一个快速修复( 使用重新编码 ):

find -name '*.java' -exec recode Latin-1..UTF-8 {} \;

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

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