Skip to content

Instantly share code, notes, and snippets.

@Porges
Created March 21, 2012 03:32
Show Gist options
  • Save Porges/2144059 to your computer and use it in GitHub Desktop.
Save Porges/2144059 to your computer and use it in GitHub Desktop.
Example for StackOverflow #9798033/
public static void Main(string[] args)
{
var s = "<x>els o, ø and y\u001a</x>".Replace((char)0x1a, ' ');
var utf8 = Encoding.UTF8.GetBytes(s);
var utf16 = Encoding.Unicode.GetBytes(s);
using (MemoryStream memoryStream = new MemoryStream(utf8))
using (XmlTextReader xsText = new XmlTextReader(memoryStream))
{
xsText.Normalization = true;
while(xsText.Read())
{
Console.WriteLine(xsText.Value);
}
}
using (MemoryStream memoryStream = new MemoryStream(utf16))
using (XmlTextReader xsText = new XmlTextReader(memoryStream))
{
xsText.Normalization = true;
while(xsText.Read())
{
Console.WriteLine(xsText.Value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment