JavaScript:gb2312轉unicode — 形式

來源:互聯網
上載者:User
<html>
<head>
<title>gb2312 unicode轉換工具</title>
<div align=center>
<center>
<table border=0 cellpadding=0 cellspacing=0 style="border-collapse: collapse" width=600 id=AutoNumber1 height=26>
  <tr>
    <td width=100% height=26>
    <p align=center><font face=黑體 size=5 color=#FF0000>unicode  轉換工具</font></p>
    <p>使用方法:</p>
    <p>  在下面的文字框中輸入中文文字,按“轉化”,即可將其轉化為unicode字元。</p>
    <p>  再按“還原”,即可將其還原為簡體中文。</td>
  </tr>
</table>
</center>
</div>
<p align=center>
<textarea cols=82 rows=10 id=code>
</textarea> </p>
<p align=center>

<input 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,"$2;")});
       btn.value="還原";
       mode="huan";
   }else{
       obj.value=unescape(obj.value.replace(//g,'%u').replace(/;/g,''));
       btn.value="轉化";
       mode="zhuan";
   }
}
</script></p>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.