我正在通过PHP及其方法imap_open获取我在GMail账户中未读邮件。
当我通过方法imap_fetch_overview获取主题时,我得到了一些像这样的主题:
=?ISO-8859-1?Q?Informaci=F3n_Apartamento_a_la_Venta?= =?ISO-8859-1?Q?_en_Benasque(Demandas:_0442_______)?=
这篇文章无法阅读,我认为是由于字符编码的问题。
要使其可读,应该怎么做呢?
我正在通过PHP及其方法imap_open获取我在GMail账户中未读邮件。
当我通过方法imap_fetch_overview获取主题时,我得到了一些像这样的主题:
=?ISO-8859-1?Q?Informaci=F3n_Apartamento_a_la_Venta?= =?ISO-8859-1?Q?_en_Benasque(Demandas:_0442_______)?=
这篇文章无法阅读,我认为是由于字符编码的问题。
要使其可读,应该怎么做呢?
要获取UTF-8字符串,请执行以下操作:
$or = '=?ISO-8859-1?Q?Informaci=F3n_Apartamento_a_la_Venta?= =?ISO-8859-1?Q?_en_Benasque(Demandas:_0442_______)?=';
mb_internal_encoding('UTF-8');
$v = str_replace("_"," ", mb_decode_mimeheader($or));
这将会得到:
Benasque出售公寓信息(需求:0442)
如果需要,您可以 转换 为ISO-8859-1编码。
$or = '=?ISO-8859-1?Q?Informaci=F3n_Apartamento_a_la_Venta?= =?ISO-8859-1?Q?_en_Benasque(Demandas:_0442_______)?=';
mb_internal_encoding('UTF-8');
$v = str_replace("_"," ", mb_decode_mimeheader($or));
对我有效(谢谢artefacto)