This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unicode-names.html
97 lines (86 loc) · 2.14 KB
/
unicode-names.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unicode Names</title>
<script src="unicode-names.js"></script>
<script>
//<![CDATA[
function convert () {
var iput = document.getElementById("input").value;
var rslt = document.getElementById("result");
resultstr="Result:\n";
rslt.innerHTML="";
var i =0;
var flag = false;
for (i=0;i<iput.length;i++) {
var ccode=iput.charCodeAt(i)
if(flag) {
ccode=((ccodea - 0xD800) * 0x400) + (ccode - 0xDC00) + 0x10000;
flag=false;
} else{
if(ccode >= 0xD800 && ccode < 0xDC00 ){
var ccodea=ccode;
flag=true;
}
}
if(!flag) {
var hex=ccode.toString(16);
var namestr = nms[ccode];
if(namestr==null) {
if(ccode >= 0x4E00 && ccode <= 0x9FCC) {
namestr = "CJK Ideograph " + hex;
} else if(ccode >= 0xAC00 && ccode <= 0xD7A3) {
namestr = "Hangul Syllable " + hex;
} else if(ccode >= 0xE000 && ccode <= 0xF8FF) {
namestr = "Private Use " + hex;
} else if(ccode >= 0x20000 && ccode <= 0x2B81D) {
namestr = "CJK Ideograph " + hex;
} else if(ccode >= 0xF0000 && ccode <= 0x10FFFD) {
namestr = "Private Use " + hex;
} else {
namestr="??";
}
}
while (hex.length < 4) {
hex = "0" + hex;
}
var pad = " "
if(hex.length==5) pad=" ";
if(hex.length==6) pad="";
resultstr = resultstr + "\n" + pad + "U+" + hex + " " + namestr;
}
}
rslt.innerHTML=resultstr;
}
function clearForm () {
document.getElementById("input").value="";
}
function updateURL () {
var t = document.getElementById("input").value;
document.location.search = "?" + encodeURI(t);
}
function fillForm() {
if(document.location.search != "") {
document.getElementById("input").value=decodeURI(document.location.search.substring(1));
convert();
}
}
window.addEventListener('load', fillForm, false);
//]]>
</script>
</head>
<body>
<p><button onclick="clearForm()">Clear</button>
<button onclick="updateURL()">Update URL</button>
</p>
<textarea id="input" cols="80" rows="10">
test this
𝔱𝔢𝔰𝔱 𝔱𝔥𝔦𝔰
</textarea>
<br/>
<button onclick="convert()">Convert</button>
<pre id="result">
</pre>
</body>
</html>