Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Oct 15, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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

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

No branches or pull requests

1 participant