Re: Sql server to xml string with encoding

From: Urban Andersson (anderssonurban_at_hotmail.com)
Date: 06/22/04


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



Relevant Pages

  • Re: XMLWriter Anyway to produce Doc with no encoding Info>
    ... They can't tell what encoding you'll end ... public class NullEncodingStringWriter: StringWriter ... MemoryStream as the stream to write to and uses null as the encoding. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sql server to xml string with encoding
    ... > encoding when writing to the stream instead of UTF-8 wich the data is not? ... It doesn't matter how the data is stored in the database - by the time ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: VW --> Bianary file into CLOB or BLOB
    ... Page 1252 encoding, which is normal Windows encoding for Western European ... the database as I manage this on both PostgreSQL, Oracle and ODBC ... My outstanding problem was to create a valid ByteArray from no matter ...
    (comp.lang.smalltalk)
  • Re: VW --> Bianary file into CLOB or BLOB
    ... Page 1252 encoding, which is normal Windows encoding for Western European alphabets. ... the database as I manage this on both PostgreSQL, Oracle and ODBC following the documentation. ... My outstanding problem was to create a valid ByteArray from no matter what file as I previously used the ByteArray coming from ImageReader. ...
    (comp.lang.smalltalk)
  • Re: Arabic Lanaguage support
    ... "Encoding type:" It remains blank by default. ... >> in retrieving records from the database. ... >> '%1%2%3+' etc and retrieve no records although these ... >>> A hyperlink can not retrieve data from a database. ...
    (microsoft.public.frontpage.programming)