<!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","$1;",$str);
$str = preg_replace("/%([0-9a-f]{2})/i","$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>