首页
学习
活动
专区
圈层
工具
发布

编码UTF-8
EN

Stack Overflow用户
提问于 2012-07-11 07:54:23
回答 2查看 7.4K关注 0票数 1

我的脚本不显示波兰字符。怎么修呢?谢谢。

代码语言:javascript
复制
<!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 = 'user@gmail.com';
        $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>

示例输出:

Je=B6li chcesz uatrakcyjni=E6 wygl=B1d swojej skrzynki odbiorczej za pom= oc=B1

我希望:

śli chcesz uatrakcyjnićwygląd swojej skrzynki odbiorczej za pomocą

EN

回答 2

Stack Overflow用户

发布于 2012-07-11 07:57:19

电子邮件不是在UTF-8 (引用),所以imap_utf8不工作在这里。

但是前面的一个错误是,您没有检查电子邮件使用的是哪种编码。

怎么修?

  1. 检查电子邮件/正文的编码。
  2. 然后将该编码转换为UTF-8以供显示之用。
票数 1
EN

Stack Overflow用户

发布于 2012-07-21 08:05:58

这看起来像引文-可打印编码。

只需将imap_utf8替换为解码,并使用iconv将(想必)波兰字符集转换为utf8。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11428040

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档