How to avoid native2ascii UTF Encoding BOM Header?
I use the native2ascii.exe included in the java sdk to convert ANSI text to UTF8.
native2ascii.exe开发者_Python百科 -encoding UTF8
The "problem" is: i need to avoid the auto-insert of the "\ufeff" BOM header.
Is there a simple way of avoiding that? Maybe automatically remove ti afterwards?
Thanks.
This is a won't-fix bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
As Victor pointed out, this is a no-fix 'feature'. What I do is to read the first line of text, and if the first character is the BOM then drop it.
if (firstLine.charAt(0) == '\uFEFF') { firstLine = firstLine.substring(1); }
精彩评论