Initial commit
This commit is contained in:
37
lib/unicode.php
Normal file
37
lib/unicode.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?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();
|
||||
|
Reference in New Issue
Block a user