Dave Fischetti wrote:
> Hey everyone, kinda new to this, so please bear with me.
> 
> I've been trying to get the mail parser working and was having some 
> success. I recently started getting this error when trying to parse my 
> mail. I get this with both 2006.2 and 2007.1 releases. I went and 
> deleted a few emails in my account and the problem went away. Anyone 
> know what would cause this?
> 
> *Notice*: iconv() [ function.iconv 
> <http://www.broadtexter.com/_maintenance/phpcgi/function.iconv>]: 
> Detected an illegal character in input string in 
> */usr/include/php/ezcomponents-2007.1/Mail/src/internal/charset_convert.php* 
> on line *126*

Hi Dave,

This is not an error, but a notice. The iconv() function may stumble 
upon strange characters. Probably the mail that you try to parse is not 
encoded properly.

To avoid this you can define your own character conversion function:

1. Create a new function which is similar to convertToUTF8Iconv from 
ezcMailCharsetConverter, but which supresses notices and errors (with @):

<code>
class myConverter
{
     public static function convertToUTF8IconvNoNotices( $text, 
$originalCharset )
     {
         if ( $originalCharset === 'unknown-8bit' || $originalCharset 
=== 'x-user-defined' )
         {
             $originalCharset = "latin1";
         }
         return @iconv( $originalCharset, 'utf-8', $text );
     }
}
</code>

2. Use the created function instead of the normal one (set this before 
parsing mail):

<code>
ezcMailCharsetConverter::setConvertMethod( array( 'myConverter', 
'convertToUTF8IconvNoNotices' ) );
</code>

You can also use the other examples from the ezcMailCharsetConverter 
class in case there are missing characters after parsing the mail. See 
http://php.net/manual/en/function.iconv.php to find out how //IGNORE and 
//TRANSLIT options work for iconv().

Hope this helps.

Cheers,
Alex.

-- 
Alexandru Stanoi
eZ Components System Developer
eZ Systems | http://ez.no
-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to