Created
January 30, 2012 06:27
-
-
Save haacked/1702906 to your computer and use it in GitHub Desktop.
Round Tripping UTF-8
This file contains hidden or 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
using System; | |
using System.Text; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var data = new byte[] { 128 }; | |
string text = Encoding.UTF8.GetString(data); | |
var bytes = Encoding.UTF8.GetBytes(text); | |
Console.WriteLine("Original:\t" + String.Join(", ", data)); | |
Console.WriteLine("Round Tripped:\t" + String.Join(", ", bytes)); | |
Console.ReadKey(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment