代码如下:
<style type="text/css">
<!--body,td,th {
font-size: 12px;
color: #000000;}--></style>
<title>UTF-8字符与GB2312中文编码在线转换</title><body>
<table width="514" height="407" border="0" align="center" cellpadding="1" bordercolor="#666666" bgcolor="#EEEEDD" style="border-style: solid; border-color: rgb(204, 204, 204) gray gray rgb(204, 204, 204); border-width: 1px 2px 2px 1px;"><td>
<div align="center" id="mynav2" style="WIDTH: 100%">
<p><strong>UTF8转换工具(UTF-8字符与GB2312中文编码在线转换)</strong></p>
<div id="NewsContentLabel"><div align="center" id="mynav" style="WIDTH: 100%"><div align="center"></div>
</div>
<p align="center">使用方法:在下面的文本框中输入中文文字,按“转化”,即可将其转化为UTF-8字符。</p>
<p align="left">再按“还原”,即可将其还原为简体中文。</p>
</div>
<div id="Message"></div>
<p align=center>
<textarea name="" cols="" rows=13 id=code style="WIDTH: 95%">
</textarea>
</p>
<p align=center>
<input type=button onclick=encode(code,this) value=" 转 换 ">
<script>
var mode="zhuan";
function encode(obj,btn){
if(mode=="zhuan"){
obj.value=obj.value.replace(/[^\u0000-\u00FF]/g,function($0){return escape($0).replace(/(%u)(\w{4})/gi,"&#x$2;")});
btn.value=" 还 原 ";
mode="huan";
}else{
obj.value=unescape(obj.value.replace(/&#x/g,'%u').replace(/;/g,''));
btn.value=" 转 换 ";
mode="zhuan";
}
}
</script>
</p>
</div></table>
<DIV align="center">
<p>CopyRight <STRONG><A href="http://429006.com/">Pop's Blog</A><br>
</p>
</DIV>