Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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);
Console.WriteLine("Round trip successful!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment