Note that there are some explanatory texts on larger screens.

plurals
  1. PODecoding 8bit mail message: Content-Transfer-Encoding: 8bit
    primarykey
    data
    text
    <p>I'm developing an email viewer which one reads .eml files and displays the message in a browser control. I've found code snippet and it can display 7bit and quoted-printable messages (Content-Transfer-Encoding: quoted-printable / Content-Transfer-Encoding: base64). <strong>What I need is decoding 8bit messages.</strong></p> <pre><code> private static AlternateView ImportText(StringReader r, string encoding, System.Net.Mime.ContentType contentType) { string line = string.Empty; StringBuilder b = new StringBuilder(); while ((line = r.ReadLine())!= null) { switch (encoding) { case "quoted-printable": if (line.EndsWith("=")) { b.Append(DecodeQuotedPrintables(line.TrimEnd('='), contentType.CharSet)); } else { b.Append(DecodeQuotedPrintables(line, contentType.CharSet) + "\n"); } break; case "base64": b.Append(DecodeBase64(line, contentType.CharSet)); break; case "8bit": // I need an 8bit decoder here!!! b.Append(IneedAn8bitDecoderHere(line, contentType.CharSet)); break; default: b.Append(line); break; } } AlternateView returnValue = AlternateView.CreateAlternateViewFromString(b.ToString(), null, contentType.MediaType); returnValue.TransferEncoding = TransferEncoding.QuotedPrintable; return returnValue; } </code></pre> <p>I googled for an 8bit decoder but couldn't find any. Do I really need an 8bit decoder here and do you know a good working one?</p> <p><strong>UPDATE:</strong></p> <p><strong>Related headers:</strong></p> <pre><code> MIME-Version: 1.0 Content-Type: text/plain; charset="koi8-r"; Content-Transfer-Encoding: 8bit </code></pre> <p><strong>Body message in my code (string line):</strong></p> <pre><code> ����������� �� ����, � ����� ��� � ������ ��������� ������� � �������� �������� �� ������� </code></pre> <p><strong>What Outlook displays in real world:</strong></p> <pre><code> Фантастично но факт, я снова как и раньше сделалась статной и красивой примерно за месяцок </code></pre> <p>I think I don't need <strong>case "8bit":</strong> part. As SLaks mentioned, I need to load mail source into byte array instead of string at the very beginning of the process. Examining the <strong>charset=</strong> in mail header from byte array will give the appropriate code page.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload