marcolopes
marcolopes

Reputation: 9288

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 -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.

Upvotes: 1

Views: 911

Answers (2)

rossum
rossum

Reputation: 15683

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

Upvotes: 1

Viktor Klang
Viktor Klang

Reputation: 26597

This is a won't-fix bug: https://bugs.java.com/bugdatabase/view_bug?bug_id=4508058

Upvotes: 1

Related Questions