note 71717 added to ref.curl
| From: | dan at relax dot dk | Date: | Wed, 13 Dec 2006 09:37:26 +0000 |
| Subject: | note 71717 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120567@lists.php.net to get a copy of this message | ||
This really bugged me for a long time...
I have created a curl class, that I use every day - unfortunately some people just won't stay
within the standards, so sometimes I get some HTML with lots of weird characters, that were supposed
to be ie. ø...
but looks all weird!
curl doesn't support encoding, but I've found, that this is what is needed to convert
those annoying characters:
Instead of the real character, you get 2 - the first is chr 195 and the other is the orginal
character - 64 ~ (chr(2nd char)+64) = the original, intended character!
Hope this helps some-one or more! :-)
Heres a function that takes care of thos annoying chars:
function charset_fix($TheString) {
if(preg_match('/('.chr(195).')(.)/', $TheString, $match)) {
$TheString = preg_replace('/'.chr(195).$match[2].'/',
chr(ord($match[2])+64), $TheString);
}
return $TheString;
}
----
Server IP: 195.184.96.15
Probable Submitter: 87.49.114.39
----
Manual Page -- http://www.php.net/manual/en/ref.curl.php
Edit -- https://master.php.net/note/edit/71717
Del: integrated -- https://master.php.net/note/delete/71717/integrated
Del: useless -- https://master.php.net/note/delete/71717/useless
Del: bad code -- https://master.php.net/note/delete/71717/bad+code
Del: spam -- https://master.php.net/note/delete/71717/spam
Del: non-english -- https://master.php.net/note/delete/71717/non-english
Del: in docs -- https://master.php.net/note/delete/71717/in+docs
Del: other reasons-- https://master.php.net/note/delete/71717
Reject -- https://master.php.net/note/reject/71717
Search -- https://master.php.net/manage/user-notes.php