Skip to content

Instantly share code, notes, and snippets.

@CloCkWeRX
Created June 5, 2012 05:51
Show Gist options
  • Save CloCkWeRX/2872946 to your computer and use it in GitHub Desktop.
Save CloCkWeRX/2872946 to your computer and use it in GitHub Desktop.
<?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