WordPress.org

Ready to get started?Download WordPress

Forums

Let WordPress RSS Function Support Mutil Charset (1 post)

  1. szpunk
    Member
    Posted 9 years ago #

    WordPress 1.5 Above support rss fetch like dashboard wordpress news.But it is'nt support mutil charset like gb2312,big5,shift js etc......Because wordpress use magpierss 0.51 core ,that didnt support mutil charset;
    But MagpieRSS version 0.72 support mutil charset now,why wordpress 2.0 RC use old version 0.51 however?

    you can replace rss-functions.php line 48:
    $parser = @xml_parser_create();
    to:
    //-------------------Instaniate an XML parser under PHP4--------------------------------//

    if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
    $encoding = strtoupper($m[1]);
    } else {
    $encoding = "UTF-8";
    }

    if($encoding == "UTF-8" || $encoding == "US-ASCII" || $encoding == "ISO-8859-1") {
    $parser = xml_parser_create($encoding);
    } else {

    if(function_exists('mb_convert_encoding')) {
    $encoded_source = @mb_convert_encoding($source, "UTF-8", $encoding);
    }

    if(function_exists('iconv')) {
    $encoded_source = @iconv($encoding, "UTF-8", $source);
    }

    if($encoded_source != NULL) {
    $source = str_replace ( $m[0],'<?xml version="1.0" encoding="utf-8"?>', $encoded_source);
    }

    $parser = xml_parser_create("UTF-8");
    }

    xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");

    //-------------------------------------------------------------------------------------------------//
    or download my fix file : http://www.quakemachine.com/blog/wp-content/files/rss-functions.rar

    Wish WordPress Offcily support these.

    Reference: http://burl.fergcorp.com/minutillo/48ba5

Topic Closed

This topic has been closed to new replies.

About this Topic