`
dreamstone
  • 浏览: 283837 次
  • 来自: ...
文章分类
社区版块
存档分类

Native2Ascii的JavaScript实现 (便于平时使用)

阅读更多
 1 <! DOCTYPE HTML PUBLIC  " -//W3C//DTD HTML 4.0 Transitional//EN " >
 2 < HTML >
 3      < HEAD >
 4          < TITLE >
 5             New Document
 6          </ TITLE >
 7          < META NAME = " Generator "  CONTENT = " EditPlus " >
 8          < META NAME = " Author "  CONTENT = "" >
 9          < META NAME = " Keywords "  CONTENT = "" >
10          < META NAME = " Description "  CONTENT = "" >
11          < script language = " javascript " >
12 function native2ascii()  {
13     regexp  =   / [ ^ \x00 - \xff] / g;
14     n  =  document.getElementById( ' native ' ).value;
15     a  =  n;
16      while (m  =  regexp.exec(n))  {
17         a  =  a.split(m[ 0 ]).join(escape(m[ 0 ]).split( ' % ' ).join( ' \\ ' ));
18     }

19     document.getElementById( ' ascii ' ).value  =  a;
20 }

21 function ascii2native()  {
22      // regexp = /[^\x00-\xff]/g;
23     a  =  document.getElementById( ' ascii ' ).value;
24     n  =  a;
25     n  =  unescape(n.split( ' \\ ' ).join( ' % ' ));
26     document.getElementById( ' native ' ).value  =  n;
27 }

28 </ script >
29      </ HEAD >
30      < BODY >
31          < textarea id = " native "  rows = " 10 "  cols = " 100 " ></ textarea >
32          < />
33              < input type = " button "  id = " convert "  value = " convert "  onclick = " native2ascii() "   />
34              < input type = " button "  id = " back "  value = " back "  onclick = " ascii2native() "   />
35             
36          < />
37              < textarea id = " ascii "  rows = " 10 "  cols = " 100 " ></ textarea >
38      </ BODY >
39 </ HTML >
40
41

文件下载:http://www.blogjava.net/Files/dreamstone/native2ascii.rar
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics