Blog Stats
  • Posts - 104
  • Articles - 0
  • Comments - 160
  • Trackbacks - 383

 

some interesting responses on UTF-16 problem with XMLTextWriter

 This is what hb replied with :

yar may be, because
utf-16 is two byte per character.
so with string writer its unicode.
if u enforece ascii then utf-8 would be there.

(note: my reply is just an argument, i might need correction, so dont hesitate to correct me)

---
hB


I replied hb's mail as following:

yes exactly thats wat the point is.. it sounds reasonable for string writer to generate a utf-16 prologues .. but my amazement revolves around the fact there isnt any support for parametrizing prologue specually encoding specs..


This is what Ahsan had to add:

There is one thing that i think you are missing here. you should be using XmlTextWriter for writing xml to stream.
Dim writer As New System.Xml.XmlTextWriter("", System.Text.Encoding.Unicode)

here you specify the encoding for the xml so it spefically know in which way it should be written.

Stringwriter is generic for all types of files, it will not cater specifics of the xml schema

Also please read this
http://support.microsoft.com/kb/q275883/
This tell the capabilities of IE


Follwing is my response to Ahsan's mail:

Ahsan my friend! you dint get me right. System.Xml.XMLTextWriter has three constructors

1- public XmlTextWriter(Stream, Encoding);// IOStream required
2- public XmlTextWriter(TextWriter); // valid reference to TextWriterRequired
3- public XmlTextWriter(string, Encoding); // string is for FileName

The problem is I dont want to user stream (binary or filestream). I want to build an an in memory representation of XML Document without using binary/file stream ( requirement!). Now I am left with using only constrcutor number 2.

And I believe you know that TextWriter is an abstract base class so I am left to look for any of the two implementations 1- StreamWriter and 2- StringWriter. And you can realize i cant go for option 1 so it has to be StringWriter and thats where I faced the problem that i posted. What do you say ?

System.IO.StringWriter stringWriter = new System.IO.StringWriter();
System.Xml.XmlTextWriter xmlTextWriter = new System.Xml.XmlTextWriter(stringWriter);
xmlTextWriter.WriteStartDocument(); // here it writes prologue :/



Hammad Rajjoub,
MVP (Windows Server System - XML Web Services),
User Group Leader - Dot Net Wizards (
http://dotnetwizards.blogspot.com),
Chariman UG Relations Committee (
http://inetapakistan.org),
Member Speakers Bureau (
http://mea.ineta.org)


Feedback

# Действительно интересно

Gravatar Действительно отличный блог! Спасибо огромное и… разумеется, пишите еще!
5/28/2009 3:09 AM | мeнимбaлaм

# Отлично

Gravatar Конечно, действительно так оно и есть. :)
6/17/2009 3:45 AM | мaлышyля

# Просто отлично

Gravatar Что то Автор почти совсем перестал писать темы и даже админить блог? Может чего случилось?
7/14/2009 5:51 AM | Глеб

# fdsgsdfgsdf dfsgdsfgsd dfsgdfg

Gravatar dsfgsdfg dfssdfgf fdsgsdfgsd 8/1/2009 4:57 PM | escattfoedo

# Жесть

Gravatar Круто написано. Можно сказать за душу цепляет, ну и заставляет задуматься над собственным блогом.
8/21/2009 4:28 AM | Станислав Конев

# Увлекательно

Gravatar Ну и после такого, как говорится, хотелось бы заслушать начальника транспортного цеха ;)
9/16/2009 5:29 AM | пyпo

# Любопытно

Gravatar Увлекательно, а продолжение будет?
10/24/2009 6:59 AM | XOglan

# Занятно

Gravatar Премного благодарен, что просветили, и, главное, как раз вовремя. Подумать только, шесть лет уже в инете, но про это первый раз слышу.
11/5/2009 4:32 PM | Всеволод Ильин

Post a comment





 

 

 

Copyright © INETA Pakistan