<html>
<head>
<title>编码(作者:余振清,NSN:wangzhankeji@hotmail.com,QQ:524689774,主页:www.66dn.com)</title>
<script>
function doit() {
var str = source.value;
var tmp1 = "";
var tmp2 = "";
var tmp3 = "";
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) < 128) {
tmp1 += str.charAt(i);
tmp2 += str.charAt(i);
tmp3 += str.charCodeAt(i) + ",";
}
else {
tmp1 += "&#"+str.charCodeAt(i)+";";
tmp2 += "//u"+(str.charCodeAt(i)).toString(16);
tmp3 += str.charCodeAt(i) + ",";
}
}
dest1.value = tmp1;
dest2.value = tmp2;
dest3.value = tmp3;
}
function doAntiHtml() {
var str = dest1.value;
var tmp1 = "";
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) == 10) {
tmp1 += "<br/>";
}
else if (str.charCodeAt(i) == 13) {
}
else if (str.charAt(i) == '<') {
tmp1 += "&";
}
else if (str.charAt(i) == '>') {
tmp1 += "&";
}
else {
tmp1 += str.charAt(i);
}
}
var dd = window.open("");
dd.document.body.innerHTML = tmp1;
}
function doAntiJava() {
var str = dest2.value;
var tmp1 = "";
for (var i = 0; i < str.length; i++) {
if (str.charCodeAt(i) == 10) {
tmp1 += "<br/>";
}
else if (str.charCodeAt(i) == 13) {
}
else if (str.charAt(i) == '<') {
tmp1 += "&";
}
else if (str.charAt(i) == '/'') {
tmp1 += "///'";
}
else if (str.charAt(i) == '//') {
if (i < (str.length - 1) && str.charAt(i + 1) != 'u') {
tmp1 += "";
}
else {
tmp1 += "//";
}
}
else if (str.charAt(i) == '>') {
tmp1 += "&";
}
else {
tmp1 += str.charAt(i);
}
}
var dd = window.open("");
dd.document.write("<script>document.write('"+tmp1+"');");
dd.document.write("<");
dd.document.write("/script>");
}
</script>
</head>
<body>
源数据:<textarea id="source" rows="6" cols="60"></textarea> <input type="button" value="编码"
οnclick="doit();"/><br/><br/>
HTML Unicode编码:<textarea id="dest1" rows="6" cols="60"></textarea></textarea> <input type="button" value="反编码"
οnclick="doAntiHtml();"/> <br/><br/>
JAVA Unicode编码:<textarea id="dest2" rows="6" cols="60"></textarea></textarea> <input type="button" value="反编码"
οnclick="doAntiJava();"/> <br/><br/>
Unicode编码值:&&&<textarea id="dest3" rows="6" cols="60"></textarea> <br/><br/>
</body>
</html>