Unicode 编码转换器 1.0

<html>
<head>
<title>Unicode 编码转换器</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<style type=text/css>
body { background-color: white; margin-top: 24px; }
h1 { font: normal 20px '黑体'; text-align: center; color: black; }
td, textarea, input, select { font: normal 12px 'Courier New'; color: black; }
</style>

<script language="JavaScript">

function paste() { //粘帖
    var clipboard = window.clipboardData.getData('text');
    clipboard == null ? alert('您的剪切板中没有任何文本内容') : source.value = clipboard;
}

function A2U() { //ASCII -> Unicode转换
    if (parseFloat(ScriptEngineMajorVersion() + '.' + ScriptEngineMinorVersion()) < 5.5) { alert('您的脚本引擎版本过低,请升级为5.5以上'); return; }
    if (source.value == '') { alert('文本框中没有代码'); return; }
    result.value = '';
    for (var i=0; i<source.value.length; i++)
    result.value += '&#' + source.value.charCodeAt(i) + ';';
}

function U2A() { //Unicode -> ASCII转换
    var code = source.value.match(/&#(/d+);/g);
    if (code == null) { alert('文本框中没有合法的Unicode代码'); return; }
    result.value = '';
    for (var i=0; i<code.length; i++)
    result.value += String.fromCharCode(code[i].replace(/[&#;]/g, ''));
}

function preview() { //预览
    var win = window.open();
    win.document.open('text/html', 'replace');
    win.document.writeln(result.value);
    win.document.close();
}

function copy() { //复制
    result.value == '' ? alert('没有需要复制的代码') : window.clipboardData.setData('text', result.value);
}
</script>

</head>

<body>
<table width="750" align="center"><tr><td>
<h1>Unicode 编码转换器 1.0</h1>
<hr>
<input type="button" value="1.粘帖" οnclick="paste();">(将需要进行转换的代码粘帖到下面的文本框中)
<textarea style="width:750px;height:180px;" id="source"></textarea><br><br>
<hr>
2.<input type="button" value="ASCII -&gt; Unicode" οnclick="A2U();"> <input type="button" value="Unicode -&gt; ASCII" οnclick="U2A();">(点击相应格式转换按钮将完成代码的转换)
<textarea style="width:750px;height:180px;" id="result"></textarea><br><br>
<hr>
<input type="button" value="3.预览" οnclick="preview()">(查看转换后的效果)
<img width="100" height="1">
<input type="button" value="4.复制" οnclick="copy();">(复制转换后的代码到剪贴板中)
<br>
<hr>
</td></tr></table>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值