Seriously annoying encoding issue which I can't fix!!!
Posted: Sun Jan 25, 2009 4:58 am
Although the utf-8 code units for the Euro sign (€) are "E2 82 AC", the following code returns "C2 80":
http://bugs.php.net/bug.php?id=22277 says:
Can anyone please tell me how I get from the Euro sign to "E2 82 AC"?
Many thanks.
Code: Select all
<?
function str2hex ( $string )
{
for ( $i = 0; $i < strlen ( $string ) ; $i++ ) $result .= str_pad ( dechex ( ord ( $string[$i] ) ) , 2, 0, STR_PAD_LEFT ) ;
return $result;
}
echo str2hex(utf8_encode("€"));
?>
I've tried using iconv as well, but to no avail.utf8_encode() only supports iso-8859-1 to UTF-8 conversion, whilst the charset that covers euro sign is iso-8859-15. Try iconv extension instead.
Can anyone please tell me how I get from the Euro sign to "E2 82 AC"?
Many thanks.