Created
September 3, 2016 11:15
-
-
Save juanparati/06fa5c68070ea00dbb92db04eb0e1cfa 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
function unicode2utf8($c) | |
{ | |
$output=""; | |
if($c < 0x80) | |
{ | |
return chr($c); | |
} | |
else if($c < 0x800) | |
{ | |
return chr( 0xc0 | ($c >> 6) ).chr( 0x80 | ($c & 0x3f) ); | |
} | |
else if($c < 0x10000) | |
{ | |
return chr( 0xe0 | ($c >> 12) ).chr( 0x80 | (($c >> 6) & 0x3f) ).chr( 0x80 | ($c & 0x3f) ); | |
} | |
else if($c < 0x200000) | |
{ | |
return chr(0xf0 | ($c >> 18)).chr(0x80 | (($c >> 12) & 0x3f)).chr(0x80 | (($c >> 6) & 0x3f)).chr(0x80 | ($c & 0x3f)); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment