开发者

PHP's cUrl function returning bad characters

开发者 https://www.devze.com 2023-02-18 23:13 出处:网络
I\'m attempting to retrieve a remote HTML page with cURL - however, when I analyze the text that gets returned, I\'m noticing al开发者_JAVA技巧ot of odd characters like ▀Ã, which makes me

I'm attempting to retrieve a remote HTML page with cURL - however, when I analyze the text that gets returned, I'm noticing al开发者_JAVA技巧ot of odd characters like ▀Ã, which makes me think that something went wrong with the text encoding somewhere along the line.

How can I ensure that the text I get back from cURL is properly encoded, and how can I normalize it so I can safely store results in a database without any encoding issues?


I hope you have set CURLOPT_ENCODING to "" and the page is not full of those gibberish which you see, second thing I can suggest is to run the string through some thing like html entities to sanitise it. Curl simply gets/posts the data and, IMHO, doesn't change the encodings


You need to include the following on the top of your page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

0

精彩评论

暂无评论...
验证码 换一张
取 消