roundcubemail/program/lib/Roundcube/rcube_message.php
public static function format_part_body($body, $part, $default_charset = null)
    {
        // remove useless characters
        $body = preg_replace('/[\t\r\0\x0B]+\n/', "\n", $body);

        // remove NULL characters if any (#1486189)
        if (strpos($body, "\x00") !== false) {
            $body = str_replace("\x00", '', $body);
        }

        // detect charset...
        if (!$part->charset || strtoupper($part->charset) == 'US-ASCII') {
            // try to extract charset information from HTML meta tag (#1488125)
            if ($part->ctype_secondary == 'html' && preg_match('/<meta[^>]+charset=([a-z0-9-_]+)/i', $body, $m)) {
                $part->charset = strtoupper($m[1]);
            }
            else if ($default_charset) {
                $part->charset = $default_charset;
            }
            else {
                $rcube         = rcube::get_instance();
                $part->charset = $rcube->config->get('default_charset', RCUBE_CHARSET);
            }
        }

        // ..convert charset encoding
        $body = rcube_charset::convert($body, $part->charset);

        return $body;
    }
public static function format_part_body($body, $part, $default_charset = null)
    {
        // remove useless characters
        $body = preg_replace('/[\t\r\0\x0B]+\n/', "\n", $body);

        // remove NULL characters if any (#1486189)
        if (strpos($body, "\x00") !== false) {
            $body = str_replace("\x00", '', $body);
        }

        // detect charset...
        if (!$part->charset || strtoupper($part->charset) == 'US-ASCII') {
            // try to extract charset information from HTML meta tag (#1488125)
            if ($part->ctype_secondary == 'html' && preg_match('/<meta[^>]+charset=([a-z0-9-_]+)/i', $body, $m)) {
                $part->charset = strtoupper($m[1]);
            }
            else if ($default_charset) {
                $part->charset = $default_charset;
            }
            else {
                $rcube         = rcube::get_instance();
                $part->charset = $rcube->config->get('default_charset', RCUBE_CHARSET);
            }
        }

        // ..convert charset encoding
        $body = rcube_charset::convert($body, $part->charset);

        return $body;
    }
public static function format_part_body ( $ body , $ part , $ default_charset = null ) { // remove useless characters $ body = preg_replace ( '/[\t\r\0\x0B]+\n/' , "\n" , $ body ) ; // remove NULL characters if any (#1486189) if ( strpos ( $ body , "\x00" ) !== false ) { $ body = str_replace ( "\x00" , '' , $ body ) ; } // detect charset... if ( ! $ part -> charset || strtoupper ( $ part -> charset ) == 'US-ASCII' ) { // try to extract charset information from HTML meta tag (#1488125) if ( $ part -> ctype_secondary == 'html' && preg_match ( '/<meta[^>]+charset=([a-z0-9-_]+)/i' , $ body , $ m ) ) { $ part -> charset = strtoupper ( $ m [ 1 ] ) ; } else if ( $ default_charset ) { $ part -> charset = $ default_charset ; } else { $ rcube = rcube :: get_instance ( ) ; $ part -> charset = $ rcube -> config -> get ( 'default_charset' , RCUBE_CHARSET ) ; } } // ..convert charset encoding $ body = rcube_charset :: convert ( $ body , $ part -> charset ) ; return $ body ; }
Format text message part for display

@param string             $body            Part body
@param rcube_message_part $part            Part object
@param string             $default_charset Fallback charset if part charset is not specified

@return string Formatted body
Format text message part for display