veluit06 Posted July 21, 2009 Share Posted July 21, 2009 Any one can help me "Decimal, Hexadecimal Character Codes in HTML Unicode" concept, Please view this link http://code.cside.com/3rdpage/us/unicode/converter.html how to do in PHP this same concept, please anyone guide me, help me Quote Link to comment https://forums.phpfreaks.com/topic/166750-decimal-hexadecimal-character-codes/ Share on other sites More sharing options...
Mark Baker Posted July 21, 2009 Share Posted July 21, 2009 These two functions might get you started function Number_to_Character($number) { if (function_exists('mb_convert_encoding')) { return mb_convert_encoding('&#'.intval($number).';', 'UTF-8', 'HTML-ENTITIES'); } else { return chr(intval($number)); } } function Character_to_Number($characters) { if ((function_exists('mb_strlen')) && (function_exists('mb_substr'))) { if (mb_strlen($characters, 'UTF-8') > 0) { $character = mb_substr($characters, 0, 1, 'UTF-8'); $byteLength = strlen($character); $xValue = 0; for ($i = 0; $i < $byteLength; ++$i) { $xValue = ($xValue * 256) + ord($character{$i}); } return $xValue; } } else { if (strlen($characters) > 0) { return ord(substr($characters, 0, 1)); } } return false; } for some reason, it's sticking a spurious 38;# in line 3.... should be a simple '&#' Quote Link to comment https://forums.phpfreaks.com/topic/166750-decimal-hexadecimal-character-codes/#findComment-879308 Share on other sites More sharing options...
veluit06 Posted July 21, 2009 Author Share Posted July 21, 2009 Thanks can u please explain this code. Quote Link to comment https://forums.phpfreaks.com/topic/166750-decimal-hexadecimal-character-codes/#findComment-879332 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.