The email subject is encoded in accordance with RFC 2047. We can decode it using the mu_rfc2047_decode() function provided by GNU mailutils. Example:
#include <stdio.h> #include <stdlib.h> #include <mailutils/mailutils.h> #include <mailutils/mime.h> ... char cipher[] = "=?GB2312?B?UmWjujEy1MK8xruuse0=?="; char *plaintext; int rc = mu_rfc2047_decode("utf-8", cipher, &plaintext); if (rc) { fprintf(stderr, "Fail to decode '%s'\n", cipher); } else { puts(plaintext); free(plaintext); }
To download GNU mailutils, visit https://mailutils.org/
To understand RFC 2047, read https://www.ietf.org/rfc/rfc2047.txt
Test result:
Cipher: **Subject: =?iso-8859-1?Q?=A1Hola,_se=F1or!?=** Plaintext: **Subject: ¡Hola, señor!** Cipher: =?Big5?Q?=AE=F8=B6O=BA=A18=A4d=BFW=AEa?= Plaintext:消費滿8千獨家Cipher: =?GB2312?B?UmWjujEy1MK8xruuse0=?= Plaintext: Re:12月计划表
source share