1

I am using this method to create a java enum for countries.

This compiles fine on my windows dev box, however when building on unix server it fails with this error :

error: unmappable character for encoding UTF8

This is caused by characters such as Å. What is the best way to handle this problem ?

Community
  • 1
  • 1
NimChimpsky
  • 46,453
  • 60
  • 198
  • 311

1 Answers1

1

Your source code file obviously uses a different encoding than UTF-8, while the Java compiler on the Unix server is using UTF-8 as default encoding.

Decide on a fixed encoding for your Java source files (probably UTF-8 is the best fit) and tell the Java compiler that the source code is UTF-8 encoded. How to do that, depends on which build system you are using.

jarnbjo
  • 33,923
  • 7
  • 70
  • 94
  • I know everybody won't agree but in a mixed operating systems / mixed IDE environment what worked best for us was to put extremely strict yet very simple guidelines in place: you *must not* put any non-ASCII character in a *.java* source file. This is enforced by custom build scripts: the build instantly fails upon any violation to this rule. We did so because there's no metadata describing the encoding of a *.java* file and there are too many tools (IDEs, diff tools, scripts, etc.) that can fail. People should either use escaping or externalize the strings (properties, XML, whatever). – TacticalCoder Dec 20 '11 at 12:56