// 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; using System.Text.RegularExpressions; namespace E { public class MainClass { public static string Decode(string s) { MatchCollection rr = Regex.Matches(s, @"(?:=\?)([^\?]+)(?:\?B\?)([^\?]*)(?:\?=)"); string charset = rr[0].Groups[1].Value; string data = rr[0].Groups[2].Value; byte[] b = Convert.FromBase64String(data); string res = Encoding.GetEncoding(charset).GetString(b); return res; } public static void Main(string[] args) { string s = "=?utf-8?B?QVVUTyBQRU9QTEUgLS0gTWFuaGVpbeKAmXMgSmVmZiBCdW5jaCBpbiBIaWdoYmVhbXM7IExlZ2VuZGFyeSBSZWQgTWNDb21iczsgV2hv4oCZcyBTaGlmdGluZyBHZWFycz87IE1vcmU=?="; Console.WriteLine(Decode(s)); } } }