Created
March 21, 2012 03:32
-
-
Save Porges/2144059 to your computer and use it in GitHub Desktop.
Example for StackOverflow #9798033/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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