Re: Xml Encoding Problem!!!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 06/23/04


Date: Wed, 23 Jun 2004 21:15:48 +0100

Vai2000 <nospam@microsoft.com> wrote:
> Hi All, I have an xml document which gets generated out of a process with
> utf-16 type of encoding. I am writing this to a file. How can I convert it
> to utf-8 since IE won't open the Document.
> Tried using Encoding.Unicode,Encoding.Utf8 flags in the StreamWriter but no
> luck!!!
>
> // this is the code I am using to write out
> StreamWriter sw=new StreamWriter(fileOut);
> sw.Write(content,Encoding.Unicode);
> //sw.Write(content,Encoding.Utf8);
> sw.Close();

Not sure what you're doing in that code - the StreamWriter should have
a UTF-8 encoding by default.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Relevant Pages

  • Xml Encoding Problem!!!
    ... I have an xml document which gets generated out of a process with ... utf-16 type of encoding. ... I am writing this to a file. ... Tried using Encoding.Unicode,Encoding.Utf8 flags in the StreamWriter but no ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Invalid high surrogate character (0xDEB6).
    ... Microsoft MSDN Online Support Lead ... Should I be encoding the text somehow? ... Invalid high surrogate character. ... I am building an XML document using the standard calls to create ...
    (microsoft.public.dotnet.xml)
  • Re: Creating ANSI text files with international characters
    ... I've got the vCalendar part right, except for the file encoding. ... What exactly do you mean by "ANSI" here? ... No. Create a FileStream, and then a StreamWriter on top of that, ... If you specify the correct encoding, ...
    (microsoft.public.dotnet.framework)
  • Re: Problems with special characters in XML
    ... i would guess that your problem is to do with the HTTP encoding. ... your web service is sending a HTTP header specifying UTF-8 encoding (which ... the XML document is able to read out the encoding ...
    (microsoft.public.dotnet.xml)
  • Re: Writing German characters to sequential file
    ... specify a German code page in the stream writer command? ... You must choose one that contains the Umlaut, for example codepage ... don't pass an Encoding object to the StreamWriter. ...
    (microsoft.public.dotnet.languages.vb)