中文转换Ascii和Unicode编码小工具-代码
2009-05-15 15:18
357 查看
<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,"$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>
<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,"$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>
相关文章推荐
- 通用数字中文互转换工具代码
- 采用native2ascii工具将中文字符的资源文件转换为Unicode代码格式的文件
- 中文汉字 | ASCII | Unicode互相转换工具
- js 中文汉字转Unicode、Unicode转中文汉字、ASCII转换Unicode、Unicode转换ASCII、中文转换XX函数代码
- 在线中文--ASCII转换工具
- sql注入代码转换工具
- C#和VB.NET代码互相转换工具
- 一段把客户端的中文字串转换成UTF-8的代码
- android findview 自动生成工具 xml布局文件自动转换类模板代码工具
- 5个最优秀的Java和C#代码转换工具
- Python 3中的json.dumps,会将中文转换为unicode编码后保存
- 使用Java将中文字符转换成Unicode编码
- 四款工具顺利实现Python与JavaScript间的代码转换
- jdk自带的将中文转换为ASCII码的工具
- 推荐几款常用在线代码转换工具
- Android NDK的C/C++代码中利用JNI回调实现字符编码转换的试验(中文UTF8与GBK)
- js 16进制Unicode编码与中文相互转换
- 一些C#代码 与 VB.net 代码的转换的工具
- 在eclipse中安装properties插件PropertiesEditor及设置(附图),ASCII码转换成中文 安装成功后ASCII还是不能转换成中文的,原因是设置里面没有把编码设置为utf8的
- n个VB.Net C#代码转换工具