<html>
<head>
<script>
function encode2ascii(s,t){
t.value="";
var str=s.value;
t.value=str.replace(/[^/u0000-/u00FF]/g,function($0){return escape($0).replace(/(%u)(/w{4})/gi,"//u$2")});
}
function encode2unicode(s,t){
t.value="";
var str=s.value;
t.value=str.replace(/[^/u0000-/u00FF]/g,function($0){return escape($0).replace(/(%u)(/w{4})/gi,"&#x$2;")});
}
</script>
</head>
<body>
源码:
<br>
<textarea rows=5 id="source" style="WIDTH: 70%"></textarea>
<p>
<input type="button" onclick="encode2ascii(source,target)" value="转化Ascii编码">
<input type="button" onclick="encode2unicode(source,target)" value="转化Unicode编码">
<p>
转换结果:
<br>
<textarea rows=5 id=target style="WIDTH:70%"></textarea>
</body>
</html>