I have the following line:
=?utf-8?Q?=5Bproconact_=2D_Verbesserung_=23=32=37=39=5D_=28Neu=29_Stellvertretungen_Benutzerrecht_=2D_andere_k=C3=B6nnen_f=C3=BCr_andere_Stellvertretungen_erstellen_=C3=A4ndern_usw=2E_dadurch_ist_der_Schutz_der_Aktivi=C3=A4ten_Mails_nicht_gew=C3=A4hrt=...
which is an encoding
[proconact-Verbesserung
I am looking for a way to decode a quoted string.
I tried:
private static string DecodeQuotedPrintables(string input, string charSet) { Encoding enc = new ASCIIEncoding(); try { enc = Encoding.GetEncoding(charSet); } catch { enc = new UTF8Encoding(); } var occurences = new Regex(@"(=[0-9A-Z]{2}){1,}", RegexOptions.Multiline); var matches = occurences.Matches(input); foreach (Match match in matches) { try { byte[] b = new byte[match.Groups[0].Value.Length / 3]; for (int i = 0; i < match.Groups[0].Value.Length / 3; i++) { b[i] = byte.Parse(match.Groups[0].Value.Substring(i * 3 + 1, 2), System.Globalization.NumberStyles.AllowHexSpecifier); } char[] hexChar = enc.GetChars(b); input = input.Replace(match.Groups[0].Value, hexChar[0].ToString()); } catch { ;} } input = input.Replace("?=", "").Replace("=\r\n", ""); return input; }
when i call (where s is my string)
var x = DecodeQuotedPrintables(s, "utf-8");
it will return
=?utf-8?Q?[proconact_-_Verbesserung_
What can I do to remove _ and start =?utf-8?Q?
and final =..
?
source share