开发者

compilation error regarding unmappable character for encoding UTF-8

开发者 https://www.devze.com 2023-01-26 01:06 出处:网络
//Fahrenheit (°F) I have the above code commented out in my java code, but I get the \"unmappable character for e开发者_开发技巧ncoding UTF-8\". How do I fix this?You need to specify the encoding i
  //  Fahrenheit (°F)

I have the above code commented out in my java code, but I get the "unmappable character for e开发者_开发技巧ncoding UTF-8". How do I fix this?


You need to specify the encoding in your javac command line using the -encoding flag

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.


Having this same compiler error with a ton of java files in the ISO-8859-1. Opening one by one is impracticable. So, here's a quick fix (using recode):

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

精彩评论

暂无评论...
验证码 换一张
取 消