Fix for XML encoding from membuffer

This commit is contained in:
Rick Falkvinge
2015-08-26 17:13:34 +02:00
parent 73e08508b2
commit 2bb89efe75
2 changed files with 12 additions and 2 deletions
@@ -17,7 +17,12 @@ namespace Swarmops.Logic.Communications.Transmission
serializer.Serialize (stream, this);
byte[] xmlBytes = stream.GetBuffer();
return Encoding.UTF8.GetString (xmlBytes);
string xml = Encoding.UTF8.GetString (xmlBytes);
xml = xml.Replace("�", "");
xml = xml.Replace("\x00", "");
return xml;
}
public static T FromXml (string xml)
+6 -1
View File
@@ -16,7 +16,12 @@ namespace Swarmops.Logic.Support.LogEntries
serializer.Serialize (stream, this);
byte[] xmlBytes = stream.GetBuffer();
return Encoding.UTF8.GetString (xmlBytes);
string xml = Encoding.UTF8.GetString (xmlBytes);
xml = xml.Replace("�", "");
xml = xml.Replace("\x00", "");
return xml;
}
public static T FromXml (string xml) // 'T' might not work here, like it didn't in ToXml()