M
Martin Z
Hi,
I have an application that involves sending a lot of XML data to
various places. The problem is that once in a while, I just want the
XML document as a string (for example, sending to a typed dataset
tableadaptor). In that case, I have a problem: what encoding do I use
to conver the byte[] (or memorystream) into a string? The encoding is
in the file, of course, like any XML file, but how do I find out
which? I tried using an XmlTextReader - this is supposed to have an
Encoding... but all I did basically was
myEncoding = new XmlTextReader(myMemoryStream).Encoding;
and in that case it's null. Is there something I have to do with the
textreareader to get it to populate it's own "Encoding" field from the
given text? The presence of a null indicates I'm doing something
really wierd, since the documentation for XmlTextReader.Encoding says:
Property Value
The encoding value. If no encoding attribute exists, and there is no
byte-order mark, this defaults to UTF-8.
I have an application that involves sending a lot of XML data to
various places. The problem is that once in a while, I just want the
XML document as a string (for example, sending to a typed dataset
tableadaptor). In that case, I have a problem: what encoding do I use
to conver the byte[] (or memorystream) into a string? The encoding is
in the file, of course, like any XML file, but how do I find out
which? I tried using an XmlTextReader - this is supposed to have an
Encoding... but all I did basically was
myEncoding = new XmlTextReader(myMemoryStream).Encoding;
and in that case it's null. Is there something I have to do with the
textreareader to get it to populate it's own "Encoding" field from the
given text? The presence of a null indicates I'm doing something
really wierd, since the documentation for XmlTextReader.Encoding says:
Property Value
The encoding value. If no encoding attribute exists, and there is no
byte-order mark, this defaults to UTF-8.