// 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.Drawing; using System.Windows.Forms; using System.Text; namespace E { public class MainForm : Form { private TextBox textBox1; private Button button1; private Button button2; private Button button3; public MainForm() { InitializeComponent(); } [STAThread] public static void Main(string[] args) { Application.Run(new MainForm()); } private void InitializeComponent() { textBox1 = new TextBox(); button1 = new Button(); button2 = new Button(); button3 = new Button(); SuspendLayout(); textBox1.Location = new Point(50, 50); textBox1.Size = new Size(100, 25); textBox1.Text = ""; button1.Location = new Point(50, 100); button1.Size = new Size(100, 25); button1.Text = "default"; button1.Click += new System.EventHandler(Button1Click); button2.Location = new Point(50, 150); button2.Size = new Size(100, 25); button2.Text = "UTF8"; button2.Click += new System.EventHandler(Button2Click); button3.Location = new Point(50, 200); button3.Size = new Size(100, 25); button3.Text = "850"; button3.Click += new System.EventHandler(Button3Click); ClientSize = new Size(200, 300); Controls.Add(button3); Controls.Add(button2); Controls.Add(button1); Controls.Add(textBox1); Text = "MainForm"; ResumeLayout(false); } private byte[] b = { 146, 145 }; void Button1Click(object sender, System.EventArgs e) { textBox1.Text = Encoding.Default.GetString(b); } void Button2Click(object sender, System.EventArgs e) { textBox1.Text = Encoding.UTF8.GetString(b); } void Button3Click(object sender, System.EventArgs e) { textBox1.Text = Encoding.GetEncoding(850).GetString(b); } } }