Native2Ascii的JavaScript實現(xiàn) (便于平時使用)
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
< p />
33
< input type = " button " id = " convert " value = " convert " onclick = " native2ascii() " />
34
< input type = " button " id = " back " value = " back " onclick = " ascii2native() " />
35
36
< p />
37
< textarea id = " ascii " rows = " 10 " cols = " 100 " ></ textarea >
38
</ BODY >
39
</ HTML >
40
41

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

文件下載:http://www.aygfsteel.com/Files/dreamstone/native2ascii.rar
posted on 2006-11-20 10:46 dreamstone 閱讀(2513) 評論(2) 編輯 收藏 所屬分類: 利器 、腳本語言javascript