开发者

ASCII-characters instead of Swedish chars?

开发者 https://www.devze.com 2023-01-11 13:46 出处:网络
I have tested PHP\'s IMAP lib. to fetch emails from a GMAIL account, but I\'ve just can\'t get my head around trying to make the characters to display correctly.

I have tested PHP's IMAP lib. to fetch emails from a GMAIL account, but I've just can't get my head around trying to make the characters to display correctly.

At first, I was close to pull my hair off when I realized that I accidentally fetched the attachments instead of the message body - not good, but now when that is solved, I still have problems viewing the actual messages with appropriate Swedish characters, like åÅ开发者_高级运维 äÄ öÖ which instead appear as their ASCII-cousins; =E4, =E5 - and so on.

What is the appropriate way to solve this? I've tested all encoding functions that I can think of by myself - and it won't work...

Thanks!


Not 100% sure, but it seems to me that the content of the message is quoted-printable encoded. Try quoted_printable_decode - http://www.php.net/manual/en/function.quoted-printable-decode.php

If you are already using the IMAP extension, you can also try imap_qprint - http://www.php.net/manual/en/function.imap-qprint.php


Try this

function fixEncoding($in_str) {
      $cur_encoding = mb_detect_encoding($in_str) ;
      if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
         return $in_str;
      else
         return utf8_encode($in_str);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号