April 28, 2011

There is no Unicode byte order mark. Cannot switch to Unicode

Issue: {There is no Unicode byte order mark. Cannot switch to Unicode}

Reason:  Data/xml/text is in different encoding & you are trying to read/process it in different encoding.

Steps: it can occur with Microsoft .net application, asp.net mvc or any java, php applicaiton.

Just confirm that. if you are reading a stream or file, explicitly specify the encoding rather that rely on default encoding select by CLR. 
You may have to put some more lines in the code because some time the method you are using does not have parameter for that. so you have to go additional step to provide stream which is having that parameter and supply it.



XmlSerializer xs = new XmlSerializer(typeof(T)); return (T)xs.Deserialize(reader);


XmlSerializer xs = new XmlSerializer(typeof(T)); MemoryStream memoryStream = new MemoryStream(StringToASCIIByteArray(xml)); XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII); return (T)xs.Deserialize(memoryStream);

No comments: