// 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; namespace E { public class Program { public static void Test(string s, string fnm, Encoding enc) { using(StreamWriter sw = new StreamWriter(@"C:\" + fnm, false, enc)) { sw.WriteLine(s); } } public static void Main(string[] args) { string s = "ABCabc123ÅÄÖåäö"; Test(s, "utf8.txt", Encoding.UTF8); Test(s, "utf16.txt", Encoding.GetEncoding("UTF-16")); Test(s, "cp1252.txt", Encoding.GetEncoding(1252)); } } }