Skip to content

@Haacked /windows-1252-roundtrip.cs
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.