Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: UTF-8 and BOM

On a page of Java's Bug Database http://bugs.sun.com/view_bug.do?bug_id=4508058 it reads that Sun/Oracle will not fix the problem of Java not parsing the BOM of a UTF-8-encoded string. Since the most recent comment on this page dates back to 2010, I would like to know if there is any younger info about that? Is it still true that Java cannot handle BOM of UTF-8?

like image 235
gefei Avatar asked Mar 26 '12 16:03

gefei


1 Answers

Yes, it is still true that Java cannot handle the BOM in UTF8 encoded files. I came across this issue when parsing several XML files for data formatting purposes. Since you can't know when you might come across them, I would suggest stripping the BOM marker out if you find it at runtime or following the advice that tchrist gave.

like image 144
Ocracoke Avatar answered Oct 19 '22 22:10

Ocracoke