Omitting Byte Order Mark
Posted on 2006-11-28
I'm using .net 1.1 and am trying to write UTF-8 XML without a Byte Order Mark. According to everything I have read, this shouldn't be hard, but unfortunately it isn't proving that easy for me. Here's the code I'm working with
XmlDataDocument doc = new XmlDataDocument();
XmlTextWriter fs = new XmlTextWriter(fileName, new System.Text.UTF8Encoding(false));
This *kind of* works in the sense that the UTF-8 BOM is not included in the file, however the UTF-16 BOM (FF FE) is included in the file.
Replacing the XmlTextWriter declaration Encoding argument with "null" will remove all BOMs, however the text is then ASCII encoded and not UTF-8. I'm really trying to figure out how to write UTF-8 WITHOUT a BOM. Any help would be greatly appreciated.