38 lines
873 B
PHP
38 lines
873 B
PHP
<?php
|
|
|
|
class UnicodeShim
|
|
{
|
|
public static function bind()
|
|
{
|
|
static $init;
|
|
|
|
if ($init++) return;
|
|
|
|
function uchr($ord)
|
|
{
|
|
return json_decode('"'.'\u'.dechex($ord).'"');
|
|
}
|
|
|
|
function uprintf($arg)
|
|
{
|
|
$str = call_user_func_array('sprintf', func_get_args());
|
|
$str = preg_replace_callback("/(\\\\u[0-9a-f]{1,4})/i", function ($chr) {
|
|
return json_decode('"'.$chr[1].'"');
|
|
}, $str);
|
|
echo $str;
|
|
}
|
|
|
|
function usprintf($arg)
|
|
{
|
|
$str = call_user_func_array('sprintf', func_get_args());
|
|
$str = preg_replace_callback("/(\\\\u[0-9a-f]{1,4})/i", function ($chr) {
|
|
return json_decode('"'.$chr[1].'"');
|
|
}, $str);
|
|
return $str;
|
|
}
|
|
}
|
|
}
|
|
|
|
UnicodeShim::bind();
|
|
|