forked from ygs-code/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
charCodeAt.html
73 lines (69 loc) · 2.49 KB
/
charCodeAt.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
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function charCodeAt(exp) {
let c, i;
for (i = 0; i < exp.length; i++) {
c = exp.charCodeAt(i);
switch (c) {
case 0x22:
console.log('c=' + c)
console.log('0x22=' + exp[i])
break // 匹配 "
case 0x27:
console.log('c=' + c)
console.log('0x27=' + exp[i])
break // 匹配 '
case 0x60:
console.log('c=' + c)
console.log('0x60=' + exp[i])
break // 匹配 `
case 0x28:
console.log('c=' + c)
console.log('0x28=' + exp[i])
break // 匹配 (
case 0x29:
console.log('c=' + c)
console.log('0x29=' + exp[i])
break //匹配 )
case 0x5B:
console.log('c=' + c)
console.log('0x5B=' + exp[i])
break // 匹配 [
case 0x5D:
console.log('c=' + c)
console.log('0x5D=' + exp[i])
break // 匹配 ]
case 0x7B:
console.log('c=' + c)
console.log('0x7B=' + exp[i])
break // 匹配 {
case 0x7D:
console.log('c=' + c)
console.log('exp[i]=' + exp[i])
break // }
case 0x5C: // 匹配 \
console.log('c=' + c)
console.log('0x5C=' + exp[i])
break
case 0x2f: // 匹配 /
console.log('c=' + c)
console.log('0x5C=' + exp[i])
break
case 0x7C: // 匹配 pipe
console.log('c=' + c)
console.log('0x7C=' + exp[i])
debugger;
break
}
}
}
charCodeAt(`"'()[]{} '\\ \/ pipe`);
</script>
</body>
</html>