- 论坛徽章:
- 1
|
- $str = phpUnescape("您的");
- echo($str);
- function phpUnescape($str)
- {
- $str = rawurldecode($str);
- preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U", $str, $regs);
- $ary = $regs[0];
- foreach($ary as $k => $v)
- {
- if (substr($v, 0, 2) == "%u")
- {
- $ary[$k] = iconv("UCS-2", "GB2312", pack("H4", substr($v, -4)));
- } elseif (substr($v, 0, 3) == "&#x")
- {
- $ary[$k] = iconv("UCS-2", "GB2312", pack("H4", substr($v, 3, -1)));
- } elseif (substr($v, 0, 2) == "&#")
- {
- $ary[$k] = iconv("UCS-2", "GB2312", pack("n", substr($v, 2, -1)));
- }
- }
- return join("", $ary);
- }
复制代码 |
|