Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove the BOM character from my xml file [duplicate]

People also ask

What is BOM character in XML?

The Byte-Order-Mark (or BOM), is a special marker added at the very beginning of an Unicode file encoded in UTF-8, UTF-16 or UTF-32. It is used to indicate whether the file uses the big-endian or little-endian byte order. The BOM is mandatory for UTF-16 and UTF-32, but it is optional for UTF-8.

What is BOM in character encoding?

What is a byte-order mark? At the beginning of a page that uses a Unicode character encoding you may find some bytes that represent the Unicode code point U+FEFF BYTE ORDER MARK (abbreviated as BOM ). The name BYTE ORDER MARK is an alias for the original character name ZERO WIDTH NO-BREAK SPACE (ZWNBSP).


# vim file.xml
:set nobomb
:wq

just need to add this in your xslt file:

<xsl:output method="text"
        encoding="ASCII"/>

Just strip first two bytes using any hex editor.


Remove the BOM symbol from string with XSLT is pretty simple:

<xsl:value-of select="translate(StringWithBOM,'','')"/>