{"id":242,"date":"2013-10-30T13:58:28","date_gmt":"2013-10-30T12:58:28","guid":{"rendered":"http:\/\/www.ingby.com\/?p=242"},"modified":"2015-03-09T18:57:00","modified_gmt":"2015-03-09T17:57:00","slug":"java-encoding-of-source-files","status":"publish","type":"post","link":"https:\/\/www.ingby.com\/?p=242","title":{"rendered":"Java encoding of source files"},"content":{"rendered":"<p>I got a problem with some java source files, which <em>javac<\/em> couldn&#8217;t compile, because the file encoding was correct. The source files did include some Swedish UTF-8 characters.<\/p>\n<blockquote><p>unmappable character for encoding ASCII<\/p><\/blockquote>\n<p>So I checked what my ant environment looked like:<\/p>\n<blockquote><p>$ ant -diagnostics|grep encoding<br \/>\nfile.encoding.pkg : sun.io<br \/>\nsun.jnu.encoding : ANSI_X3.4-1968<br \/>\nfile.encoding : ANSI_X3.4-1968<br \/>\nsun.io.unicode.encoding : UnicodeLittle<\/p><\/blockquote>\n<p>Definitely not the UTF-8 encoding I desired.<\/p>\n<p>Checked my environment<\/p>\n<blockquote><p>\n$ locale<br \/>\nlocale: Cannot set LC_ALL to default locale: No such file or directory<br \/>\nLANG=en_US.UTF-8<br \/>\nLANGUAGE=en_US:<br \/>\nLC_CTYPE=&#8221;en_US.UTF-8&#8243;<br \/>\nLC_NUMERIC=sv_SE.UTF-8<br \/>\nLC_TIME=sv_SE.UTF-8<br \/>\nLC_COLLATE=&#8221;en_US.UTF-8&#8243;<br \/>\nLC_MONETARY=sv_SE.UTF-8<br \/>\nLC_MESSAGES=&#8221;en_US.UTF-8&#8243;<br \/>\nLC_PAPER=sv_SE.UTF-8<br \/>\nLC_NAME=sv_SE.UTF-8<br \/>\nLC_ADDRESS=sv_SE.UTF-8<br \/>\nLC_TELEPHONE=sv_SE.UTF-8<br \/>\nLC_MEASUREMENT=sv_SE.UTF-8<br \/>\nLC_IDENTIFICATION=sv_SE.UTF-8<br \/>\nLC_ALL=\n<\/p><\/blockquote>\n<p>And then:<\/p>\n<blockquote><p>\n$ locale -a<br \/>\nC<br \/>\nC.UTF-8<br \/>\nen_AG<br \/>\nen_AG.utf8<br \/>\nen_AU.utf8<br \/>\nen_BW.utf8<br \/>\nen_CA.utf8<br \/>\nen_DK.utf8<br \/>\nen_GB.utf8<br \/>\nen_HK.utf8<br \/>\nen_IE.utf8<br \/>\nen_IN<br \/>\nen_IN.utf8<br \/>\nen_NG<br \/>\nen_NG.utf8<br \/>\nen_NZ.utf8<br \/>\nen_PH.utf8<br \/>\nen_SG.utf8<br \/>\nen_US.utf8<br \/>\nen_ZA.utf8<br \/>\nen_ZM<br \/>\nen_ZM.utf8<br \/>\nen_ZW.utf8<br \/>\nPOSIX\n<\/p><\/blockquote>\n<p>Notice that <em>sv_SE.UTF-8<\/em> is missing.<\/p>\n<blockquote><p>$ sudo locale-gen sv_SE.UTF-8<\/p>\n<p>$ sudo dpkg-reconfigure locales<\/p><\/blockquote>\n<p>Check java file encoding again:<\/p>\n<blockquote><p>$ ant -diagnostics|grep encoding<br \/>\nfile.encoding.pkg : sun.io<br \/>\nsun.jnu.encoding : UTF-8<br \/>\nfile.encoding : UTF-8<br \/>\nsun.io.unicode.encoding : UnicodeLittle<\/p><\/blockquote>\n<p>I&#8217;m running Ubuntu 12.04 Server and the previous command worked fine the other day. I guess that there was some Ubuntu update which destroyed my environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I got a problem with some java source files, which javac couldn&#8217;t compile, because the file encoding was correct. The source files did include some Swedish UTF-8 characters. unmappable character for encoding ASCII So I checked what my ant environment looked like: $ ant -diagnostics|grep encoding file.encoding.pkg : sun.io sun.jnu.encoding : ANSI_X3.4-1968 file.encoding : ANSI_X3.4-1968 &hellip; <a href=\"https:\/\/www.ingby.com\/?p=242\" class=\"more-link\">Forts\u00e4tt l\u00e4sa <span class=\"screen-reader-text\">Java encoding of source files<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[31,32,33],"tags":[30,29],"_links":{"self":[{"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/posts\/242"}],"collection":[{"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ingby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=242"}],"version-history":[{"count":2,"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/www.ingby.com\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions\/270"}],"wp:attachment":[{"href":"https:\/\/www.ingby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ingby.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ingby.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}