Russian Character encoding with IMAP

穿精又带淫゛_ 提交于 2019-12-14 03:09:48

问题


I have a PHP script that accesses an imap mailbox.

When I send through English, Spanish and French it works perfectly but Russian I realize it is probably an encoding issue but nothing I try seems to work.

this is what it printed:

PiAq8NLJ18XUIM3PyiDE0tXHKiAuCj4+Cj4+Cj4+Cj4K

   $email=$_REQUEST['email'];
  $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "info@******.com", "**********");
  $num_mensaje = imap_search($mbox,"FROM $email");      
    $body =  imap_fetchbody($mbox,$num_mensaje[0],"1");
    $str =   imap_utf8($body);
    if ($str != null){
   $arr=array('id'=>'0','email'=>"$email",'respuesta'=>"$str");
  $output[] = $arr;
   print(json_encode($output));
    }else{
   $arr2=array('id'=>'0','email'=>"$email",'respuesta'=>"norespuesta");
$output2[] = $arr2;
print(json_encode($output2));
}
imap_close($mbox);

回答1:


Convert to utf with

imap_utf8($text);

See http://php.net/manual/ru/function.imap-utf8.php for more details



来源:https://stackoverflow.com/questions/9802374/russian-character-encoding-with-imap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!