UNICODE的编码与解码
作者:大鹏 发布于:2007-3-4 15:13 Sunday 分类:JavaScript与HTML
[codes=html]
<script>
function e(s){
test=s
str=""
for(i=0;i<test.length;i++)
{
temp = test.charCodeAt(i).toString(16);
str += "\\u"+ new Array(5-String(temp).length).join("0") +temp;
}
document.getElementById('go').value=str
}
function d(s)
{
eval("document.getElementById('go').value=('"+s+"')");
}
</script>
<textarea id="go" style="width:100%;height:200px;"></textarea>
<button onclick="e(document.getElementById('go').value)">编码</button>
<button onclick="d(document.getElementById('go').value)">解码</button>
[/codes]
标签: html javascript 收藏
« 上一篇 卡号输入框 | Dr.com登陆软件使用路由器多机器上网完美解决方案 下一篇»