Closed omerilk closed 6 years ago
Thank you! I will look into this
@sergey144010 if you would.....
According to this code: public function convertToUtf8($str) { if (mb_detect_encoding($str, "UTF-8, ISO-8859-1, GBK")!="UTF-8") { $str = utf8_encode($str); } $str = iconv('UTF-8', 'UTF-8//IGNORE', $str); return $str; } If, its not utf8, we encode to utf8, then decode it. Ignoring special characters, then it retuyrns the string. Could you provide the code you are using?
function convert_to_utf8($str) {
return iconv(mb_detect_encoding($str, mb_detect_order(), true), "UTF-8", $str);
}
in Documentation i see setEncoding() but if use, get error.
Would you please post that error?
$imap = new Imap([settings]); $imap->setEncoding("utf-8"); Call to undefined method SSilence\ImapClient\ImapClient::setEncoding()
setEncoding() i see in archive/ImapClient.php in ImapClient/ImapClient.php there is no such this function
http://ssilence.github.io/php-imap-client/methods.html - in documentation setEncoding()
is there a solution to the encoding problem now? some letters are defined correctly, some are not. The methods listed in this thread do not help. checked when connecting to office 365.
Perhaps this library should look at using neitanod/forceutf8 for UTF-8 conversion?
I will look into it. However we may need a library that does more then UTF-8 as this may not be intended behavior.
Should be fixed as of latest commit.
i tested witch message in koi8-r end not work...
SSilence\ImapClient\IncomingMessage Object
(
[header] => stdClass Object
(
[subject] => RE: ???????????? ?????????? ???????????? ?
[from] => ?????? ????????
[to] => ???? ????????
Feature request or bug
bug
If a bug, what did you expect to happen?
convertToUtf8 function is converting the strings to UTF8 charset. But it is not taking care to source charset of string.
public function convertToUtf8($str) { if (mb_detect_encoding($str, "UTF-8, ISO-8859-1, GBK")!="UTF-8") { $str = utf8_encode($str); } $str = iconv('UTF-8', 'UTF-8//IGNORE', $str); return $str; }
If a bug, what happened?
if the source string is not ISO-8859-1, benerated strings by convertToUtf8 function are unreadable
If a bug, list steps to reproduce bugs.
if recipient address charset is not ISO-8859-1 or UTF-8 problem can be reproduce
If a bug, did you do these steps?
[x] Download and use the lastest stable version [x] See if the issue has already been reported [] Debug
If a feature request, what do you want to be added or changed?
If a feature request, is this feature already in a pull request?
If a feature request, do you know anyone who can help?
Side notes(Read then del this chunk)
related modifications as an example
protected function toAddress($headerinfos) { $email = ""; $name = ""; if (isset($headerinfos->mailbox) && isset($headerinfos->host)) { $email = $headerinfos->mailbox . "@" . $headerinfos->host; } if (!empty($headerinfos->personal)) { $name = imap_mime_header_decode($headerinfos->personal); $name = $name[0]->text; ++ $charset = $name[0]->charset; } else { $name = $email; } $name = $this->convertToUtf8($name, $charset); return $name . " <" . $email . ">"; }