Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subject and other texts are decoded incorrectly #3

Closed
mvar opened this issue Oct 31, 2012 · 0 comments
Closed

Subject and other texts are decoded incorrectly #3

mvar opened this issue Oct 31, 2012 · 0 comments

Comments

@mvar
Copy link
Contributor

mvar commented Oct 31, 2012

Current result: test 123 ir lietuviškos raid�s
Expected: test 123 ir lietuviškos raidės

Possible solution (partly tested):

    /**
     * Decodes IMAP encoded string (RFC2047)
     *
     * @param string $string
     *
     * @return string
     */
    public function decodeImapString($string)
    {
        $result = array();
        $parts = imap_mime_header_decode($string);

        foreach ($parts as $part) {
            if ($part->charset == 'default') {
                $result[] = $part->text;
            } else {
                $result[] = mb_convert_encoding($part->text, 'UTF-8', $part->charset);
            }
        }

        return implode($result);
    }

This logic should be applied to header lines (including attachment names)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant