静坐常思己过,闲谈莫论人非,能受苦乃为志士,肯吃亏不是痴人,敬君子方显有德,怕小人不算无能,退一步天高地阔,让三分心平气和,欲进步需思退步,若着手先虑放手,如得意不宜重往,凡做事应有余步。持黄金为珍贵,知安乐方值千金,事临头三思为妙,怒上心忍让最高。切勿贪意外之财,知足者人心常乐。若能以此去处事,一生安乐任逍遥。

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 收藏

et_highlighter
发表评论 »本文目前尚无任何评论

发表评论

干净网络从你做起,切勿黏贴小广告