Bug Report: eM Client fails to auto-detect unencoded UTF-8 Subject headers (mojibake with Hungarian/accented characters)
Summary
When a message arrives with a Subject: header containing raw, unencoded UTF-8 bytes (no RFC 2047 =?UTF-8?...?= encoded-word, no charset parameter on that header — which RFC 2047 does not even allow), eM Client mis-decodes the accented characters, producing mojibake (e.g. “kamerák” → “kamerÁ¡k”, “észlelve” → “Á©szlelve”). Thunderbird, Gmail webmail, and other major clients decode the exact same message correctly by detecting that the header bytes form valid UTF-8. eM Client appears to fall back to a single-byte codepage (looks like Windows-1252) instead.
Environment
eM Client version: 10.4.0.0 (Windows)
Account type: IMAP (Synology MailPlus Server backend)
Affected area: Message list “Subject” column and the opened message’s subject line
Steps to Reproduce
Send a message where the Subject header contains raw UTF-8 bytes with no RFC 2047 encoding, e.g. via this minimal PHP script:
// Email headers
$headers = "From: Kamera Monitor <[email protected]>\r\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
$subject = "FIGYELEM: Offline kamerák észlelve!";
$message = "...";
mail($to, $subject, $message, $headers);
Note: Content-Type: charset=UTF-8 is only set for the body; PHP’s mail() does not encode $subject — it is sent as raw UTF-8 bytes.
The resulting Subject header on the wire is (verified with a hex dump):
Subject: FIGYELEM: Offline kamerák észlelve!
UTF-8 byte sequence (hex): 46494759454c454d3a204f66666c696e65206b616d6572c3a16b20c3a9737a6c656c766521
Receive this message in eM Client (IMAP) and view it in the message list / opened message.
Receive/view the identical message in Mozilla Thunderbird and in a webmail client (e.g. Gmail).
Expected Result
Subject displays as: FIGYELEM: Offline kamerák észlelve! — as it correctly does in Thunderbird and webmail.
Actual Result
eM Client displays: FIGYELEM: Offline kamerÁ¡k Á©szlelve! (accented characters replaced by garbled multi-character sequences), both in the message list and in the opened message header.
Root Cause (as far as I can tell from the outside)
eM Client appears to strictly require an explicit RFC 2047 encoded-word or a declared charset on the header itself, and when neither is present it falls back to decoding the header bytes as a single-byte codepage (Windows-1252 or similar) rather than checking whether the bytes form valid UTF-8. Since valid multi-byte UTF-8 sequences are self-identifying (very low false-positive rate), most other clients (Thunderbird, Gmail, and others) use “if the header bytes are valid UTF-8, decode as UTF-8” as a fallback specifically to handle non-compliant senders like this one gracefully. This fallback appears to be missing in eM Client.
This Is Not a New/Isolated Report
The same underlying issue (unencoded non-ASCII header bytes decoded with the wrong charset) has been reported repeatedly over many years with different languages/scripts, with no resolution:
Cyrillic characters (2014): Encoding message subjects in utf-8
Conflicting/incorrect charset handling: Wrong codepage while displaying a message
Suggested Fix
When decoding a header field that lacks RFC 2047 encoding and contains non-ASCII bytes, validate whether the byte sequence is well-formed UTF-8 before falling back to a legacy single-byte codepage. If valid, decode as UTF-8. This is standard practice in Thunderbird, Gmail, and other major MUAs specifically to handle real-world non-compliant senders (embedded devices, simple PHP mail() scripts, legacy alert systems, etc.), which are common in practice.