Created
June 5, 2012 05:51
-
-
Save CloCkWeRX/2872946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('mb_convert_encoding')) { | |
die("Please enable the mbstring extension - http://www.php.net/manual/en/mbstring.installation.php"); | |
} | |
$in = 'John'; | |
$first_letter = substr($in, 0, 1); | |
print $first_letter . "\n"; | |
$hex = dechex(ord($first_letter)); | |
$suffix = dechex(57344); // e000; | |
$hex_combined = dechex(hexdec($hex) + hexdec($suffix)); | |
print $hex_combined . "\n"; | |
$as_decimal = hexdec($hex_combined); | |
print mb_convert_encoding('&#' . $as_decimal . ';', 'UTF-8', 'HTML-ENTITIES') . mb_convert_encoding(substr($in, 1), 'UTF-8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment