2012-01-02 138 views

回答

0

不知道关于Q-编码库,找不到任何。

待办事项,虽然,你的后一个例子看起来并不想让Q编码,请注意字符集之后的字符(“UTF-8”)是不是“Q”,但是一个“B”。这意味着它是base64编码,其中有很多库,glib就是一个例子。

关于如何检测正在使用的编码详见MIME在维基百科上。

+0

对不起你,好吧,我删除了它。那是个错误。 – iyasar 2012-01-02 13:45:27

1

电子邮件主题是根据RFC 2047,我们可以通过使用GNU mailutils提供的函数mu_rfc2047_decode()对其进行解码编码。 例子:

#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); 
} 

下载GNU mailutils,请访问https://mailutils.org/

要了解RFC 2047,读https://www.ietf.org/rfc/rfc2047.txt

测试结果:

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月计划表