Re: Sql server to xml string with encoding
From: Urban Andersson (anderssonurban_at_hotmail.com)
Date: 06/22/04
- Next message: Paul Clement: "Re: Is "OLE Objects" supported in .NET?"
- Previous message: Mary Chipman: "Re: Most Common Errors"
- In reply to: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Next in thread: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Reply: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Reply: Per Bolmstedt: "Re: Sql server to xml string with encoding"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Jun 2004 15:18:32 +0200
But the data is stored in ISO-8859-9 in the database. Is it not correct the
to set the stream to ISO-8859-9 so that the data will be converted to that
encoding when writing to the stream instead of UTF-8 wich the data is not?
It seems to me that the WriteXml method writes UTF-8 to the stream instead
of ISO-8859-9? I tried using the StringWriter but i am not able to set
the encoding.
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1b42167ef9f9a86b98ad30@msnews.microsoft.com...
> Urban Andersson <anderssonurban@hotmail.com> wrote:
> > I try to read data from a SQL server and convert it to a xml document
string
> > where the data itself is saved with different encodings. I figured out
how
> > to write the correct encoding to the string but it seems that when
reading
> > from the database the data i converted from it's original econding to
UTF-8.
> > So when i write the xml string the result will be garbled. This is what
I
> > have done so far could someone help me to get the data in correct
encoding
> > from the database?
>
> Rather than writing to a MemoryStream, write to a StringWriter. You can
> subclass StringWriter if you need an encoding other than UTF-8 to
> appear in the XML header.
>
> The database encoding shouldn't matter at all though - what you're
> doing wrong in the code you quoted is assuming that WriteXml is using
> ISO-8859-1.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
- Next message: Paul Clement: "Re: Is "OLE Objects" supported in .NET?"
- Previous message: Mary Chipman: "Re: Most Common Errors"
- In reply to: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Next in thread: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Reply: Jon Skeet [C# MVP]: "Re: Sql server to xml string with encoding"
- Reply: Per Bolmstedt: "Re: Sql server to xml string with encoding"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|