<< I Wrote a Web Service :) | Home | What Does It Print >>

Quiz: Default Encoding of Java Source Files

Quickly, without peeking into the documentation, answer this question:

When you run javac Foo.java, what encoding does the Java compiler assumes Foo.java to be in?

Is it UTF-8? UTF-16? ISO-8859-1? ASCII with escaped Unicode? Or something else?



Re: Quiz: Default Encoding of Java Source Files

I'd say UTF-8.

Re: Quiz: Default Encoding of Java Source Files

The default platform encoding.

Re: Quiz: Default Encoding of Java Source Files

It's the default platform encoding: Cp1252 on a Windows machine setup to the US English locale, and Ms932 on a Windows machine setup to the Japanese locale.

We had a unit test for a sorting routine using the Collator on accented characters that started failing with we changed the machine's regional settings from US English to Japanese.


Add a comment Send a TrackBack