src/core/framework/core/3rdparty/ezcomponents/Mail/src/tools.php
public static function mimeDecode( $text, $charset = 'utf-8' )
    {
        $origtext = $text;
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // something went wrong while decoding, let's see if we can fix it
        // Try to fix lower case hex digits
        $text = preg_replace_callback(
            '/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
            create_function( '$matches', 'return strtoupper($matches[0]);' ),
            $origtext
        );
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
        // are not understood (but only "B" and "Q")
        $text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // Try it as latin 1 string
        $text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
        $text = iconv_mime_decode( $text, 0, $charset );

        return $text;
    }
public static function mimeDecode( $text, $charset = 'utf-8' )
    {
        $origtext = $text;
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // something went wrong while decoding, let's see if we can fix it
        // Try to fix lower case hex digits
        $text = preg_replace_callback(
            '/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/',
            create_function( '$matches', 'return strtoupper($matches[0]);' ),
            $origtext
        );
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods
        // are not understood (but only "B" and "Q")
        $text = str_replace( array( '?b?', '?q?' ), array( '?B?', '?Q?' ), $origtext );
        $text = @iconv_mime_decode( $text, 0, $charset );
        if ( $text !== false )
        {
            return $text;
        }

        // Try it as latin 1 string
        $text = preg_replace( '/=\?([^?]+)\?/', '=?iso-8859-1?', $origtext );
        $text = iconv_mime_decode( $text, 0, $charset );

        return $text;
    }
public static function mimeDecode ( $ text , $ charset = 'utf-8' ) { $ origtext = $ text ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } // something went wrong while decoding, let's see if we can fix it // Try to fix lower case hex digits $ text = preg_replace_callback ( '/=(([a-f][a-f0-9])|([a-f0-9][a-f]))/' , create_function ( '$matches' , 'return strtoupper($matches[0]);' ) , $ origtext ) ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } // Workaround a bug in PHP 5.1.0-5.1.3 where the "b" and "q" methods // are not understood (but only "B" and "Q") $ text = str_replace ( array ( '?b?' , '?q?' ) , array ( '?B?' , '?Q?' ) , $ origtext ) ; $ text = @ iconv_mime_decode ( $ text , 0 , $ charset ) ; if ( $ text !== false ) { return $ text ; } // Try it as latin 1 string $ text = preg_replace ( '/=\?([^?]+)\?/' , '=?iso-8859-1?' , $ origtext ) ; $ text = iconv_mime_decode ( $ text , 0 , $ charset ) ; return $ text ; }
Decodes mime encoded fields and tries to recover from errors.

Decodes the $text encoded as a MIME string to the $charset. In case the
strict conversion fails this method tries to workaround the issues by
trying to "fix" the original $text before trying to convert it.

@param string $text
@param string $charset
@return string
Decodes mime encoded fields and tries to recover from errors .