// 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.IO; using System.Text; using System.Windows.Forms; namespace E { public class Program { public static void Main(string[] args) { byte[] byt = { 0xC0, 0xF0, 0xE3, 0xE5, 0xED, 0xF2, 0x00 }; string str = Encoding.GetEncoding(1251).GetString(byt); MessageBox.Show(str); Console.WriteLine(Encoding.GetEncoding(1251).GetBytes(str).Length); using(Stream stm = new FileStream(@"C:\z.1", FileMode.Create, FileAccess.Write)) { stm.Write(byt, 0, byt.Length); } Console.WriteLine((new FileInfo(@"C:\z.1")).Length); using(StreamWriter sw = new StreamWriter(@"C:\z.2", false, Encoding.GetEncoding(1251))) { sw.Write(str); } Console.WriteLine((new FileInfo(@"C:\z.2")).Length); } } }