note 71717 deleted from ref.curl by nlopess
| From: | nlopess@php.net | Date: | Sun, 14 Jan 2007 18:03:00 +0000 |
| Subject: | note 71717 deleted from ref.curl by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-121635@lists.php.net to get a copy of this message | ||
Note Submitter: dan at relax dot dk
----
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;
}