字符转换Unicode编码工具

来源:互联网 发布:侧边栏显示隐藏js特效 编辑:程序博客网 时间:2024/05/19 00:08

dragchong 发表的转换Unicode编码工具

 原帖: http://download.csdn.net/source/686839

 

我修改了下CSS...

 

 

 

 

-------------------------- 附代码 --------------------------------------

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml"  dir="ltr" lang="zh-cn" xml:lang="zh-cn">
<head>  <title>字符转换Unicode编码工具</title> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="content-language" content="zh-cn" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-style-type" content="text/javascript" />

  
  <script language='JavaScript'>    
  function   doit()   {    
  var   str   =   source.value;    
  var   tmp1   =   "";    
  var   tmp2   =   "";    
  var   tmp3   =   "";    
  for   (var   i   =   0;   i   <   str.length;   i++)   {    
  if   (str.charCodeAt(i)   <   128)   {    
  tmp1   +=   str.charAt(i);    
  tmp2   +=   str.charAt(i);    
  tmp3   +=   str.charCodeAt(i)   +   ",";    
  }    
  else   {    
  tmp1   +=   "&#"+str.charCodeAt(i)+";";    
  tmp2   +=   "//u"+(str.charCodeAt(i)).toString(16);    
  tmp3   +=   str.charCodeAt(i)   +   ",";    
  }    
  }    
  dest1.value   =   tmp1;    
  dest2.value   =   tmp2;    
  dest3.value   =   tmp3;    
  }    
  function   doAntiHtml()   {    
  var   str   =   dest1.value;    
  var   tmp1   =   "";    
  for   (var   i   =   0;   i   <   str.length;   i++)   {    
  if   (str.charCodeAt(i)   ==   10)   {    
  tmp1   +=   "<br/>";    
  }    
  else   if   (str.charCodeAt(i)   ==   13)   {    
  }    
  else   if   (str.charAt(i)   ==   '<')   {    
  tmp1   +=   "&";    
  }    
  else   if   (str.charAt(i)   ==   '>')   {    
  tmp1   +=   "&";    
  }    
  else   {    
  tmp1   +=   str.charAt(i);    
  }    
  }    
  var   dd   =   window.open("");    
  dd.document.body.innerHTML   =   tmp1;    
  }    
  function   doAntiJava()   {    
  var   str   =   dest2.value;    
  var   tmp1   =   "";    
  for   (var   i   =   0;   i   <   str.length;   i++)   {    
  if   (str.charCodeAt(i)   ==   10)   {    
  tmp1   +=   "<br/>";    
  }    
  else   if   (str.charCodeAt(i)   ==   13)   {    
  }    
  else   if   (str.charAt(i)   ==   '<')   {    
  tmp1   +=   "&";    
  }    
  else   if   (str.charAt(i)   ==   '/'')   {    
  tmp1   +=   "///'";    
  }    
  else   if   (str.charAt(i)   ==   '//')   {    
  if   (i   <   (str.length   -   1)   &&   str.charAt(i   +   1)   !=   'u')   {    
  tmp1   +=   "////";    
  }    
  else   {    
  tmp1   +=   "//";    
  }    
  }    
  else   if   (str.charAt(i)   ==   '>')   {    
  tmp1   +=   "&";    
  }    
  else   {    
  tmp1   +=   str.charAt(i);    
  }    
  }    
  var   dd   =   window.open("");    
  dd.document.write("<script>document.write('"+tmp1+"');");    
  dd.document.write("<");    
  dd.document.write("/script>");    
  }    
  </script>    
 
<style type="text/css">
 <!--
html,bod
{width: "738px";margin: 0PX; font:100%/120% Verdana, Arial, Helvetica, sans-serif, 宋体;
 padding: 0; margin-align: center; }
td {font-weight: bold; color:#E25B18;}
a { text-decoration:none;}
a:hover{text-decoration:none; color:red;}
 -->
 </style>   
  </head>    
  <body>     <div style='background-color: #effae4;'> &nbsp;</div>
<p align="center"><font color="#800000" face="楷体_GB2312" size="5">字符转换Unicode编码</font> </p>

<table cellspacing="12" cellpadding="0" width="550px" align="center" bgcolor="#E2F2FD" border="0">
<tbody>
<tr>
<td align="center" bgcolor="#F1F9FE">
  <textarea   id="source"   rows="6"   cols="60"></textarea>   <br/>
  源数据:<input   type="button"   value="编&nbsp;&nbsp;码"     onclick="doit();"/><br/><br/>    
   <textarea   id="dest1"   rows="6"   cols="60"></textarea></textarea>   <br/>
   HTML&nbsp;Unicode编码:<input   type="button"   value="反编码"  onclick="doAntiHtml();"/>   <br/><br/>    
  <textarea   id="dest2"   rows="6"   cols="60"></textarea></textarea>   <br/>
  JAVA&nbsp;Unicode编码:<input   type="button"   value="反编码"       onclick="doAntiJava();"/>   <br/><br/>    
  <textarea   id="dest3"   rows="6"   cols="60"></textarea>  <br/>Unicode编码值:
</td></tr></tbody></table>
<div align=right style="COLOR: #15B308;"><i><tt>
by bobo55&nbsp;&nbsp;&nbsp;<br>
Last updated:&nbsp;<script>document.write(document.lastModified)</script></tt></i>&nbsp;&nbsp;&nbsp;</div>
  </body>    
  </html>

--------------------------------------------------我是分割线--------------------------------------------------

原创粉丝点击