Re: Converting "\u00F4" style characters

From: Date: Tue, 18 May 2004 10:38:45 +0000
Subject: Re: Converting "\u00F4" style characters
References: 1 2 3  Groups: php.i18n 
Request: Send a blank email to php-i18n+get-702@lists.php.net to get a copy of this message
Michael Wallner wrote: > it seems that the function doesn't work with higher > values like "\u20AC" which is the EUR symbol :-( Hi Mike, it's most probably the font you're using that does not have support for the EUR symbol. I tested the following on my box, and it displays fine: <?php function unichr($hex) { $utf = ''; $hex = hexdec((substr($hex, 0,2) === '\\u') ? substr($hex, 2) : $hex); if ($hex < 128) { $utf = chr($hex); } elseif ($hex < 2048) { $utf .= chr(192 + (($hex - ($hex % 64)) / 64)); $utf .= chr(128 + ($hex % 64)); } else { $utf .= chr(224 + (($hex - ($hex % 4096)) / 4096)); $utf .= chr(128 + ((($hex % 4096) - ($hex % 64)) / 64)); $utf .= chr(128 + ($hex % 64)); } return $utf; } header('Content-Type: text/plain; charset: utf-8'); print unichr('\\u20AC'); ?> Most fonts (used to) only have the iso 8859-1 characters, and the EUR symbol is only added in iso 8859-15. Hope that solves your problem... Keep up the good work :) regards, asgeir

« previous php.i18n (#702) next »