PDA

Click to See Complete Forum and Search --> : **SOLVED**Delete first Byte of a File // Read last Post


Sgt-Peppa
Aug 19th, 2003, 09:06 AM
Hey all, i have a small problem and just cant find any solution to it.


I am creating a Xml Document and save this one with doc.save(path) This works all right, but I need the file to be saved UTF-8 encoded. I already have a encoding attribute in my Xml declaration, but c# doesn't seem to care about.

So heres my question, how can I save the document UTF-8 encoded?

Thanks in advance,


Stephan

axion_sa
Aug 19th, 2003, 12:20 PM
XmlDocument xmlDoc = new XmlDocument();
XmlNode encoding = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", String.Empty);
xmlDoc.AppendChild(encoding);

Sgt-Peppa
Aug 20th, 2003, 02:38 AM
I am sorry, this is not working! I already have a xmldeclaration in my Document which already contains the encoding="UTF-8". But still, if I save myXmlDoc.save(path); it saves it as whatever, but not UTF-8.

Is it possible to Convert my XmlDom to a byte array, encode that one and then save it with a Streamwriter? And how?

Or is there any other way of getting my XmlDoc UTF-8 encoded?

Thanks,

Stephan

Sgt-Peppa
Aug 20th, 2003, 04:22 AM
Hey, well i finally figuerd that one out, but have a new related problem:

Testing my Files I found out that my Xml Document definitely is UTF-8 Encoded. My Problem is that Microsoft usues a different UTF-8 Standard than java. The file creted from my C# function is supposed to be passed on to a java app. C# addes one byte at the beginnin of the document, java cant use.

NEW QUESTION: How can I open a file Binary and delete the first byte?

Thanks Stephan

Sgt-Peppa
Aug 20th, 2003, 09:38 AM
found a workaround thanks anyways

I just passed the xmldom as String to a StreamWriter which writes the doc without encoding!

Thanx anyways, Stephan