7 $val = intval(substr($val,2),16);
14 $c .= chr(0xC0 |
($val / 64));
15 $c .= chr(0x80 |
($val %
64));
19 $c .= chr(0xE0 |
(($val / 64) / 64));
20 $c .= chr(0x80 |
(($val / 64) %
64));
21 $c .= chr(0x80 |
($val %
64));
26 function uniDecode($str, $charcode="UTF-8")
28 $text = preg_replace_callback("/%u[0-9A-Za-z]{4}/", 'toUtf8', $str);
29 return mb_convert_encoding($text, $charcode, 'utf-8');
34 return iconv('UTF-8', 'GBK', uniDecode('%u' . dechex($m[1])));
39 return preg_replace_callback('/&#([0-9]+);/', 'cp', $str);
42 if (isset($_GET['fileName']))
44 $fileName = $_GET['fileName'];
46 else if(isset($argv[1]))
52 echo "Usage: In the command line: php scriptName fileName or on the web http://foobar/scriptName.php?fileName=foobar";
55 if (isset($_GET['output']))
57 $output = $_GET['output'];
59 elseif(isset($argv[2]))
65 $p = pathinfo($fileName);
66 $output = $p['basename'];
69 $file = file_get_contents($fileName);
71 file_put_contents($output, $file);