逛奔的蜗牛

我不聪明,但我会很努力

   ::  :: 新随笔 ::  ::  :: 管理 ::

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

    <meta http-equiv="Content-type" content="text/html; charset=utf-8">

    <title>Title</title>

</head>

<body style="padding: 30px;">

<?php

    $text = $_GET['text'];

    echo "收到: $text<br />";

    

    $text = utf8_unescape($text);

    echo "$text<br />";

    

    $text = utf8_unescape($text);

    echo "$text<br />";

    

    $text = utf8_unescape($text);

    echo "$text<br />";

    

    echo html_entity_decode("ö",null,'UTF-8')."<br />";

    

    echo "内容:".utf8_unescape("IT%u6709%u9053");

    

    function utf8_unescape($str) {

        $str = preg_replace("/%u([0-9a-f]{3,4}|)/i","&#x$1;",$str);

        $str = preg_replace("/%([0-9a-f]{2})/i","&#x$1;",$str);

        return html_entity_decode($str,null,'UTF-8');;

    }

?>


</body>

    <form action="unescapse.php" method="get">

        <input type="text" name="text"/>

        <input type="submit" value="Submit"/>

    </form>

    

    <script src="js/lib/jquery.js"></script>

    <script type="text/javascript">

    $(function() {

        $("input:submit").click(function() {

            // escapse(): This function encodes special characters, with the exception of: * @ - _ + . /

            // 大于255的,被编码成%u + unicode code: %u5BB9

            // 于于255的,被编码成% + unicode code : %20

            // escapse()不被转换的字符: 0-9a-zA-Z+-*/.-@

            var text = $("input:text").val();

            $("input:text").val(escape(text));

            $(this).submit();

        });

    });

    </script>

</html>

posted on 2011-02-24 01:03 逛奔的蜗牛 阅读(358) 评论(0)  编辑 收藏 引用 所属分类: 其他编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理