I have a large file consisting of bytes which are coded in code page 852. I need to read the bytes and export them to strings to put in Objects, and then serialize those objects to XML.
The mapping function for reading the bytes is:
private string Mapper(int start, int length)
{
byte[] result = new byte[length];
Array.Copy(baseFile, localOffset + start, result, 0, length);
return Encoding.ASCII.GetString(result, 0, length);
}
Where the local offset is just the position in the database. After that I use the Mapper function to fill in the string fields of my object instance, and then I just serialize it. Here's the method for that:
private string XMLify(Object node)
{
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");
var stringWriter = new StringWriter();
var serializer = new XmlSerializer(node.GetType());
serializer.Serialize(stringWriter, node, ns);
String s = stringWriter.ToString();
return s.Substring(s.IndexOf(Environment.NewLine) + 1);
}
However, when I serialize the object instance. the XML contains strings such as "& # x 0 ;" (spaces added only to display it properly) among others. That specific one was blank when viewing the database in a hex editor, and was mapped as many times as there are blank spaces.
I know the source file is in code page 852, how do I convert it to 1250 to export as XML?