// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Text; namespace E { public class MainClass { public static void Test(byte[] b1, Encoding enc) { byte[] b2 = enc.GetBytes(enc.GetString(b1)); int nerr = 0; for(int i = 0; i < b1.Length; i++) { if(b1[i] != b2[i]) nerr++; } Console.WriteLine(enc.EncodingName + ": " + nerr + " errors"); } public static void Main(string[] args) { byte[] b1 = new byte[256]; for(int i = 0; i < b1.Length; i++) { b1[i] = (byte)i; } Test(b1, Encoding.ASCII); Test(b1, Encoding.Default); } } }