Search code examples
phpiconv

Odd warning about iconv() function


I am getting the following warning in mylog file:

PHP Warning:  iconv(): Charset parameter exceeds the maximum allowed length of 64 characters in /home/jnj/PlancakeEmailParser.php on line 283

The block in question (part of the getBody() function):

if (!$detectedContentType)
    {
        // if here, we missed the text/plain content-type (probably it was
        // in the header), thus we assume the whole body is what we are after
        $body = implode("\n", $this->rawBodyLines);
    }

    // removing trailing new lines
    $body = preg_replace('/((\r?\n)*)$/', '', $body);

    if ($contentTransferEncoding == 'base64')
        $body = base64_decode($body);
    else if ($contentTransferEncoding == 'quoted-printable')
        $body = quoted_printable_decode($body);        

    if($charset != 'UTF-8') {
        // FORMAT=FLOWED, despite being popular in emails, it is not
        // supported by iconv
        $charset = str_replace("FORMAT=FLOWED", "", $charset);

        $bodyCopy = $body; 
        $body = iconv($charset, 'UTF-8//TRANSLIT', $body);

        if ($body === FALSE) { // iconv returns FALSE on failure
            $body = utf8_encode($bodyCopy);
        }
    }

    return $body;
}

I am using PlancakeEmailParser.php to parse emails. I have Googled the error and nothing pops out at me. Anyone have any ideas of how or if I need to deal with this?


Solution

  • you say you are use PlancakeEmailParser.php class.

    just search to line :-

    $bodyCopy = $body; 
    

    and change to :-

    $bodyCopy = quoted_printable_decode($body);