开发者

How to avoid native2ascii UTF Encoding BOM Header?

开发者 https://www.devze.com 2023-04-04 03:54 出处:网络
I use the native2ascii.exe included in the java sdk to convert ANSI text to UTF8. native2ascii.exe开发者_Python百科 -encoding UTF8

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); }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号