Four years to fix a trivial bug...

My friend Christopher just told me a very old bug in the JDK has eventually been fixed in Mustang!

UTF-8 encoding does not recognize initial BOM

Java does not recognize the optional BOM which can begin a UTF-8 stream. It treats the BOM as if it were the initial character of the stream.A Utf-8 stream can optionally beign with a byte order mark (see, for example This is the character FEFF, which is represented as EF BB BF in utf-8. Java's utf-8 encoding does not recognize this character as a BOM, though; the result of reading such a stream is a set of characters beginning with FEFF.

I'm glad it's now fixed! I've been working around this bug for a long time already. I've even applied some patches to work around this issue to Groovy as well as in IntelliJ IDEA -- thanks to Maxim who introduced my suggested fix inside this wonderful IDE.


© 2012 Guillaume Laforge | The views and opinions expressed here are mine and don't reflect the ones from my employer.