My Java EE web app uses XSLT transformation to produce CSV reports.
If I specify “UTF-16” as the encoding on the XSLT (which seems to be the only way to handle accented characters in the XML) then I get a byte-order-mark character at the start of the CSV output
From what I understand, this is correct behavior. The problem is that this BOM character is visible if the CSV is opened in Excel (appears as: þÿ), but not if I open it in a proper text editor 😉
How can I hide or omit this character so it isn’t visible when the file is opened in Excel?
You forgot to specify which version of XSLT you are using.
If you are using XSLT 2.0, you can suppress the BOM using the xsl:output element. For example…
What if you are using XSLT 1.0?
Here are two options: