【问题标题】:=?ISO-8859-1 in mail subject=?ISO-8859-1 在邮件主题中
【发布时间】:2011-03-28 23:38:58
【问题描述】:

我正在通过 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 encoding decoding


【解决方案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)

【讨论】:

【解决方案2】:

要获取 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));

给出:

信息 Apartamento a la Venta en Benasque(需求: 0442 )

然后,如果您愿意,您可以将convert 转换为 ISO-8859-1。

【讨论】:

  • 谢谢,这解决了字符编码和下划线问题。
猜你喜欢
  • 2015-06-25
  • 2019-05-02
  • 2015-10-11
  • 1970-01-01
  • 2011-06-10
  • 2013-01-19
  • 2012-05-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多