Skip to content

Instantly share code, notes, and snippets.

@haacked
Created January 30, 2012 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haacked/1702966 to your computer and use it in GitHub Desktop.
Save haacked/1702966 to your computer and use it in GitHub Desktop.
Windows-1252 Encoding Round Trip Demo
using System;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
var encoding = Encoding.GetEncoding(1252);
for (int b = Byte.MinValue; b <= Byte.MaxValue; b++)
{
var data = new[] { (byte)b };
string text = encoding.GetString(data);
var roundTripped = encoding.GetBytes(text);
if (!roundTripped.SequenceEqual(data))
{
Console.WriteLine("Rount Trip Failed At: " + b);
return;
}
}
Console.WriteLine("Round trip successful!");
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment