【发布时间】:2012-07-11 11:51:04
【问题描述】:
我有一个 PHP 应用程序,它可以接收多种语言的邮件,因此可以接收不同的字符集。一旦我获取邮件,它应该以 UTF-8 编码存储在 db 中。
例如我收到一封法语邮件“Une bonne journée, tout le monde!”字符集:ISO-8859-1 或韩语“좋은 일, 세계!”字符集:EUC-KR。 现在我正在使用 Zend Imap API 阅读邮件,然后使用 iconv($charset,'UTF-8//TRANSLIT',$part) 将其转换为编码 UTF-8。 $charset 从邮件中解析并替换。
但我仍然无法获得正确的结果。请告诉我解决方案是什么
【问题讨论】:
-
But I am still not able to achieve the correct results- 你得到什么结果?它们在哪些方面不正确? -
在法语的数据库中,我只得到“Une bonne journ”,而对于韩语,它是空白的。结果应该是完整的文本
-
听起来
//TRANSLIT没有玩游戏-Otherwise, str is cut from the first illegal character and an E_NOTICE is generated-开启错误报告(error_reporting(E_ALL); ini_set('display_errors', 1);-看到前面提到的E_NOTICE了吗? -
另外,如果可用,请尝试
mb_convert_encoding() -
由于 php 正在读取 ASCII 或 utf-8 我首先执行“mb_convert_encoding($part,$charset,mb_detect_encoding($part))”然后执行“iconv($charset,'UTF- 8//TRANSLIT',$part)"
标签: php email multiple-languages