Skip to content

when program is utf-8,but remote page is gbk , the wrong has occur #232

Description

@GoogleCodeExporter
My program is utf-8 no bom encode,i get remote site is gbk encode,ex 
http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球

my code is :
<code>
$url="http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球";
phpQuery::newDocumentFileHTML($url,'gbk');
$t = pq('title')->html();

echo mb_detect_encoding ($t);// result is : UTF-8
echo $t; // this is  unreadable code
</code>

i try some function ... but not find .. so i write a function 
<code>
function d_di8_open( $url )
{
    $cnt = file_get_contents($url);
    return mb_convert_encoding($cnt ,"UTF-8","GBK");
}
$url="http://tieba.baidu.com/f?ie=utf-8&kw=奇迹篮球";
phpQuery::newDocumentHTML( d_di8_open($url) );  
$t = pq('title')->html();

echo mb_detect_encoding ($t);// result is : UTF-8
echo $t; // this is right
</code>

so i think phpquery had a bug ....

Original issue reported on code.google.com by envilwind@gmail.com on 26 Aug 2013 at 11:08

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions