php-imap-client icon indicating copy to clipboard operation
php-imap-client copied to clipboard

convert_UTF8 error

Open kavs opened this issue 4 years ago • 1 comments

Feature request or bug

If a bug, what did you expect to happen?

If a bug, what happened?

If a bug, list steps to reproduce bugs.

If a bug, did you do these steps?

[] Download and use the lastest stable version [] 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)

Please use pastebin for var_dumps. Not screenies or paste blobs!
Be descriptive!
Please fill out this entire form!

kavs avatar Apr 03 '20 10:04 kavs

For someone having the same issues with the utf-8 decode for Subject and Content, you can modify the class to following:

`/** * convert to utf8 if necessary. * * @return true or false * @param $string utf8 encoded string */ protected function convertToUtf8($string, $charset = 'utf-8') { $newString = ''; $elements = imap_mime_header_decode($string);

    for($i = 0; $i < count($elements); $i++) {
        if($elements[$i]->charset == 'default') {
            $elements[$i]->charset = 'iso-8859-3';
            $elements[$i]->text = quoted_printable_decode($elements[$i]->text);
        }
        $newString .= $this->convertStringEncoding($elements[$i]->text, $elements[$i]->charset, $charset);
    }
    return $newString;
}`

That has fixed the issues for special characters and quoted encoded content.

JAKgit avatar May 27 '21 10:05 JAKgit