Note that there are some explanatory texts on larger screens.

plurals
  1. POXML serialization national chars error
    primarykey
    data
    text
    <p>EDIT:</p> <p>Doing too much.... this works for me with national chars</p> <pre><code> var xs = new XmlSerializer(typeof(ToDoItem)); var stringWriter = new StringWriter(); xs.Serialize(stringWriter, item); var test = XDocument.Parse(stringWriter.ToString()); </code></pre> <p>...where The item is the object containing strings with national chars</p> <p>/EDIT</p> <p>I did a project with serialization of some objects.</p> <p>I copied some code from examples on this site and everything worked great, till I changed framework ASP.NET from 3.5 til 4.0... (and changed ISS7 .net setting from v2.0 to v4.0)</p> <p>I am 99% sure this is the cause of the following error:</p> <p>Before this change something like this:</p> <pre><code> var test = XDocument.Parse(SerializeObject("æøåAØÅ", typeof(string))); test.Save(HttpContext.Current.Server.MapPath("test.xml")); </code></pre> <p>Would save the xml with the exact chars used.</p> <p>Now it saves this: ���A�� </p> <p>I would like: Information on settings I might have to make in IIS7</p> <p>OR</p> <p>A comment on how to change the serializing methods to handle the national chars better.</p> <p>This is the serialization code used.</p> <pre><code> private static String UTF8ByteArrayToString(Byte[] characters) { var encoding = new UTF8Encoding(); String constructedString = encoding.GetString(characters); return (constructedString); } public static String SerializeObject(Object pObject, Type type) { try { String XmlizedString = null; var memoryStream = new MemoryStream(); var xs = new XmlSerializer(type); var xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.ASCII); xs.Serialize(xmlTextWriter, pObject); memoryStream = (MemoryStream)xmlTextWriter.BaseStream; XmlizedString = UTF8ByteArrayToString(memoryStream.ToArray()); return XmlizedString.Trim(); } catch (Exception e) { //Console.WriteLine(e); return null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload