<html>
<head>
<title>UTF-8 转码工具</title>
<style type="text/css">
<!--
.bicyle {
font-family: "Times New Roman", "Times", "serif";
font-size: 12px;
background-color: #FFFFFF;
}
-->
</style>
</head>
<body>
<div align=center>
<center>
<table border=0 cellpadding=0 cellspacing=0 style="border-collapse: collapse" width=90% id=bicyle height=52>
<tr>
<td width=100% height=13> <p align=center class="bicyle"><font color=#FF0000 size=3 face=Arial, Helvetica, sans-serif><strong>UTF-8
转码工具<br>
</strong></font><font color="#0099FF">在下面的文本框中输入中文文字,按“转化”,即可将其转化为UTF-8字符。再按“还原”,即可将其还原为简体中文。</font></p>
</td>
</tr>
<tr>
<td height=6><div align="center">
<textarea name="textarea" cols=82 rows=10 id=code></textarea>
</div></td>
</tr>
<tr>
<td height=7><div align="center">
<input name="button" 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>
</div></td>
</tr>
</table>
</center>
</div>
</body>
</html>
附另一种转换代码:
<html>
<head>
<title>UTF-8 转码工具</title>
<style>
BODY {
FONT-SIZE: 9pt; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px;
}
input {
FONT-SIZE: 9pt; height: 13pt;
}
</style>
<script language="JavaScript1.2">
/*
This following code are designed and writen by Windy_sk <seasonx@163.net>
You can use it freely, but u must held all the copyright items!
*/
function Str2Unicode(str){
var arr = new Array();
for(var i=0;i<str.length;i++){
arr="&#" + str.charCodeAt(i) + ";";
}
return(arr.toString().replace(/,/g,""));
}
function Unicode2oStr(str){
var re=/&#[/da-fA-F]{1,5};/ig;
var arr=str.match(re);
if(arr==null)return("");
for(var i=0;i<arr.length;i++){
arr=String.fromCharCode(arr.replace(/[&#;]/g,""));
}
return(arr.toString().replace(/,/g,""))
}
function modi_str(){
if(document.all.text.method.checked){
if(document.all.text.decode.value!=""){
document.all.text.encode.value = Str2Unicode(document.all.text.decode.value);
}else{
document.all.text.decode.value = Unicode2oStr(document.all.text.encode.value);
}
}else{
if(document.all.text.encode.value!=""){
document.all.text.decode.value = Unicode2oStr(document.all.text.encode.value);
}else{
document.all.text.encode.value = Str2Unicode(document.all.text.decode.value);
}
}
}
</script>
<title>Unicode</title>
<form name=text>
文本原型:<br>
<textarea name="decode" cols="100" rows="10"></textarea>
<br>
转换代码:<br>
<textarea name="encode" cols="100" rows="10"></textarea>
<br>
<input type="checkbox" name="method" checked> 正向转换
<input type=button onclick="modi_str()" value=" 确 定 ">
<input type=reset value=" 清 空 ">
<input type=button onclick="document.all.text.method.checked?document.all.text.encode.select():document.all.text.decode.select()" value=" 全 选 ">
</form>
<a href="http://www.qcbf.tk" target="_blank">其成彪飞网站工作室:http://www.qcbf.tk/</a>
</body>
</html>