By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

mb_convert_encoding

P: n/a
I am running PHP version 5.2.0-8+etch3.

If I run mb_convert_encoding( $string, "UTF-8", "HTML-ENTITIES")
on a string containing "Е", it ought to produce the two bytes
whose decimal values are 208 149. But it produces the four bytes whose
decimal values are 242 175 184 159.

Is there a fix for this? Does a later version of PHP get it right, or
do I have to write my own conversion function?

Nick
--
Nick Wedd ni**@maproom.co.uk
May 23 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Nick Wedd <ni**@maproom.co.ukwrote:
I am running PHP version 5.2.0-8+etch3.

If I run mb_convert_encoding( $string, "UTF-8", "HTML-ENTITIES")
on a string containing "&#x0415;", it ought to produce the two bytes
whose decimal values are 208 149. But it produces the four bytes whose
decimal values are 242 175 184 159.

Is there a fix for this? Does a later version of PHP get it right, or
do I have to write my own conversion function?

Nick
--
Nick Wedd ni**@maproom.co.uk
Indeed, it is a bug: mbstring lacks support for numeric hex entities,
they are decoded as if were decimals, so 'x' becomes the "decimal digit"
'x'-'0'=120-48=72, from which the strange value you obtained. I already
sent a short patch to internalsATlists.php.net, hoping be the right place.

PS. If you are playing with such a conversion, chances are that your HTML
pages are not properly encoded. Sure you need to do that?

Best regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it

May 23 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.