0

useful Link to understand Encoding http://kunststube.net/encoding/ - shared by @deceze

I'm trying to detect for the chinese character but cant. When i try echo , i get this "´Ë±¦±´ÒÑϼÜ". I don't need to display it, just need to detect the characters on the html page.

//Set the post parameters curl_setopt($ch, CURLOPT_URL, 'http://bit.ly/1y'); //execute new request $htmlcode = curl_exec($ch); curl_close($ch); if (stripos($htmlcode, "已下架") !== false) { echo "True"; }else{ echo "Fail"; } 

Any suggestions would be greatly appreciated

1

1 Answer 1

2

The page is encoded as GBK. You probably save your source as UTF-8, so "已下架" is UTF-8 encoded. Therefore stripos will not match, since it just compares bytes and is not encoding aware.

Either convert $htmlcode to the encoding of your file or convert "已下架" to the encoding of $htmlcode to perform string matching. Use mb_convert_encoding or iconv.

Sign up to request clarification or add additional context in comments.

5 Comments

Like this ? iconv('GBK', 'GBK//TRANSLIT//IGNORE', $html);
No, like iconv('GBK', 'UTF-8', $html). You need to make both strings the same encoding, not convert from GBK to GBK.
Typo there , sorry. Anyway i tried that can it translated to another kind of chinese. Not that one i see in default :\ i will try compare the "different" type of character"
"Different kind of Chinese" may just be a difference in fonts for traditional/simplified and it's just a display problem; the characters are probably fine.
I looked at the page's HTTP headers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.