Rover12421's Blog

The End.

GB2312 to UTF8 HTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GB2312 TO UTF8</title>
<style type="text/css">
<!--
.STYLE1 {
 color: #9933FF;
 font-weight: bold;
}
.STYLE3 {color: #9933FF; font-weight: bold; font-size: 24px; }
body {
 background-color: #CCCCCC;
}
-->
</style>
</head>

<body>
<table width="100%" border="0"
align="center" cellpadding="2" cellspacing="0"  class="info9">
  <tbody>
    <tr>
      <td width="92%" height="120"><div align="center"><strong><font face="黑体" size="4" color="#FF0000">GB2312转换UTF-8</font></strong><br />
         </div>
        <div align="center"></div>
        <div align="center">
          <p class="STYLE3">#R.S#</p>
      </div></td>
    </tr>
    <tr>
      <td width="92%" height="250" ><center>
        <textarea name="code" cols="100" rows="20" id="code">UTF-8
#r.s#</textarea>
        <br />
        <br />
        <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,"&#x$2;")});
    btn.value="还原";
    mode="huan";
  }else{
    obj.value=unescape(obj.value.replace(/&#x/g,'%u').replace(/;/g,''));
    btn.value="转化";
    mode="zhuan";
  }
}
</script>
        <br />
      </center></td>
    </tr>
  </tbody>
</table>
<p align="center" class="STYLE1"> </p>
</body>
</html>

Comments