
I use Linux as much as possible for everything I do. However, I often develop pieces of code on Windows, eventually compiling and deploying the entire project on Linux. During my
Ant builds, I've hit all kinds of interesting problems moving Java between Linux and Windows. One of my least favorite
javac errors is the "unmappable character for encoding UTF8" which looks like this:
[javac] /home/.../htmlGenerator/EscapeText.java:113: unmappable character for encoding UTF8
[javac] case '?': sb.append("®");break;
[javac] ^
A quick solution to the compilation error is to set the LANG environment variable to
en_US.ISO-8859-1 using
export:
(mark@skull)~/build> export LANG=en_US.ISO-8859-1
(mark@skull)~/build> echo $LANG
en_US.ISO-8859-1
It took me an hour or so to figure this one out. Hopefully this post saves someone else the trouble. Continue reading for a (somewhat) technical explanation.
The Windows system I was using had
en_US.ISO-8859-1 configured as the default encoding. Therefore, special characters didn't map from
en_US.ISO-8859-1 to
en_US.UTF-8 as expected at compile time. The default character encoding scheme of the Linux box I'm using is
en_US.UTF-8 as defined in
/etc/sysconfig/i18n ...
(mark@skull)~/build> cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"
Did you find this post helpful, or at least, interesting?