我的腳本不顯示波蘭字符。如何解決它? 謝謝。IMAP - UTF-8編碼
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
header('Content-Type: text/html; charset=utf-8');
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = '[email protected]';
$password = 'pass';
$inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());
$emails = imap_search($inbox, 'ALL');
if ($emails) {
$output = '';
foreach ($emails as $email_number) {
$overview = imap_fetch_overview($inbox, $email_number, 0);
$message = imap_fetchbody($inbox, $email_number, 2);
$output.= '<div class="toggler ' . (imap_utf8($overview[0]->seen) ? 'read' : 'unread') . '">';
$output.= '<span class="subject">' . imap_utf8($overview[0]->subject) . '</span> ';
$output.= '<span class="from">' . imap_utf8($overview[0]->from) . '</span>';
$output.= '<span class="date">on ' . imap_utf8($overview[0]->date) . '</span>';
$output.= '</div>';
/* output the email body */
$output.= '<div class="body">' . imap_utf8($message) . '</div>';
}
echo $output;
}
imap_close($inbox);
?>
</body>
</html>
輸出示例:
如果= B6li希望有更多的吸引力= E6看上去= B1D您的收件箱 POM = OC = B1
我想到:
如果你想調劑您的收件箱
編碼的電子郵件的:內容類型:文本/無格式;字符集= ISO-8859-2;格式=流動; delsp = YES 內容傳輸編碼:的base64 – 2012-07-11 08:01:51
從ISO-8859-2轉換UTF-8則。這將打開''= B6'成s',見http://de.wikipedia.org/wiki/ISO_8859-2 - 還請參閱['iconv_mime_decode'](http://php.net/iconv_mime_decode)函數 – hakre 2012-07-11 08:16:35
我嘗試:mb_convert_encoding($消息, 「UTF-8」, 「ISO-8859-2」);和我的輸出是這樣的:R3J6ZWe/87NrYSBsYXRhIGkgcLNhY3plIPOzYW5pILFja2kK – 2012-07-11 10:13:04