Somehow I can't get my UTF-8 sources to play nice with Ant.
I get a whole lot of "warning: unmappable character for encoding ascii". I'm going crazy, really. Hours and hours and hours. Btw, I noticed 5 people already used the tag crazy. :-)
And yes, I've read this, this and others. Google also (the first 5 page results of at least 3 or 4 different searches, at least). There are javac options. I've tried. There is also some preset or something (sorry, 3 AM). Didn't work either.
I'm generating Android apk files with Ant. I can't use Eclipse, so no. And by the way, the ant documentation is gibberish to me. Those examples are of no use at all. I've lost count on how much I've tried.
I've tried using the Dfile.encoding option, tried mixing that with CHCP 65001 Windows command. Did all the combinations, and it even makes Ant (Javac I guess) stop spitting errors, but it still doesn't matter. My code still ends up with garbage carachters (a bunch of ?? instead of á, í etc).
Fortunately UTF-8 is the default per sé. When reading an XML document and writing it in another encoding, mostly this attribute will be patched too.
UTF-8 (UCS Transformation Format 8) is the World Wide Web's most common character encoding. Each character is represented by one to four bytes. UTF-8 is backward-compatible with ASCII and can represent any standard Unicode character.
Are you specifying the file encoding to the compiler correctly? The java compiler will otherwise default to use the platform's default encoding, which on Windows (for example) is not UTF-8. The encoding is specified by using the -encoding flag to javac.
javac -encoding utf8 ...
And in ant build.xml:
<javac ... encoding="UTF-8" ... />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With