fetching mail w Synapse decoding utf-8 in subject lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- holger.ernst · 2014-06-18 12:48 When I fetch headers via synapse i geh something like this: Subject:  =?utf-8?Q?=53=43=48=41.... when the subject is provided in UTF-8 (my assumption). How can I decode that? Best regards Holger ---------------------------------------------------------------------- 3mptyCode · 2020-03-30 19:39 Even if your post is not that new, maybe you still like to get a solution or already found a better one ? At this post you can read my workaround-solution: https://forum.lazarus.freepascal.org/index.php/topic,47556.0.html Best regards ---------------------------------------------------------------------- Remy Lebeau · 2020-03-30 21:50 Quote from: holger.ernst on June 18, 2014, 02:48:10 pmHow can I decode that? Look at RFC 2047.  The text is encoded as follows: Quoteencoded-word = "=?" charset "?" encoding "?" encoded-text "?=" For each encoded-word in the text (there may be multiple), split it into those 3 pieces, then decode the encoded-text into bytes based on the specified encoding (Q = quoted printable, B = base64), then decode those bytes into a string based on the specified charset, then replace the entire encoded-word with the decoded string. So, for example: Code: [Select]=?utf-8?Q?=53=43=48=41...?= breaks up into Code: [Select]utf-8 Q =53=43=48=41... Then "=53=43=48=41...." becomes the byte sequence Code: [Select]$53 $43 $48 $41 ... Which decoded as UTF-8 is the string 'SCHA...'. This is not very difficult to implement by hand, or you can find a 3rd party MIME library to handle it for you (FYI, Indy has built-in support for this format).