Created
April 24, 2011 14:42
-
-
Save kamawanu/939589 to your computer and use it in GitHub Desktop.
unescape unicode string and convert utf-8
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 | |
function unicode2utf8($aa){ | |
###var_dump(func_get_args()); | |
return mb_convert_encoding( pack("n", hexdec($aa[1]) ), "utf-8", "ucs2" ); | |
} | |
while( ($f=fgets(STDIN))!==false ){ | |
$a = str_replace('\\','\',$a ); | |
$a = preg_replace_callback('/\\\u([a-f0-9]{4})/i', "unicode2utf8", $f ); | |
print $a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment