-
Notifications
You must be signed in to change notification settings - Fork 8
/
unicode.go
197 lines (184 loc) · 3.61 KB
/
unicode.go
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// Copyright 2018 Hajime Hoshi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package unicode
func IsLatin(r rune) bool {
if r <= 0x02ff {
// Basic Latin
// Latin-1 Supplement
// Latin Extended-A
// Latin Extended-B
// IPA Extensions
// Spacing Modifier Letters
return true
}
if 0x1d00 <= r && r <= 0x1dbf {
// Phonetic Extensions
// Phonetic Extensions Supplement
return true
}
if 0x1e00 <= r && r <= 0x1eff {
// Latin Extended Additional
return true
}
if 0x2070 <= r && r <= 0x209f {
// Superscripts and Subscripts
return true
}
if 0x2c60 <= r && r <= 0x2c7f {
// Latin Extended-C
return true
}
if 0xa720 <= r && r <= 0xa7ff {
// Latin Extended-D
return true
}
if 0xab30 <= r && r <= 0xab6f {
// Latin Extended-E
return true
}
if 0xfb00 <= r && r <= 0xfb06 {
// Alphabetic Presentation Forms
return true
}
return false
}
func IsGreek(r rune) bool {
if 0x0370 <= r && r <= 0x03ff {
// Greek and Coptic
return true
}
if 0x1d00 <= r && r <= 0x1dbf {
// Phonetic Extensions
// Phonetic Extensions Supplement
return true
}
if 0x1F00 <= r && r <= 0x1fff {
// Greek Extended
return true
}
if 0xab30 <= r && r <= 0xab6f {
// Latin Extended-E
return true
}
return false
}
func IsCyrillic(r rune) bool {
if 0x0400 <= r && r <= 0x052f {
// Cyrillic
// Cyrillic Supplement
return true
}
if 0x1c80 <= r && r <= 0x1C8f {
// Cyrillic Extended-C
return true
}
if 0x1d00 <= r && r <= 0x1d7f {
// Phonetic Extensions
return true
}
if 0x2de0 <= r && r <= 0x2dff {
// Cyrillic Extended-A
return true
}
if 0xa640 <= r && r <= 0xa69f {
// Cyrillic Extended-B
return true
}
if 0xFE20 <= r && r <= 0xfe2f {
// Combining Half Marks
return true
}
return false
}
func IsArmenian(r rune) bool {
if 0x0530 <= r && r <= 0x058f {
// Armenian
return true
}
if 0xfb00 <= r && r <= 0xfb4f {
// Alphabetic Presentation Forms
return true
}
return false
}
func IsHebrew(r rune) bool {
if 0x0590 <= r && r <= 0x05ff {
// Hebrew
return true
}
if 0xfb00 <= r && r <= 0xfb4f {
// Alphabetic Presentation Forms
return true
}
return false
}
func IsThai(r rune) bool {
if 0x0e00 <= r && r <= 0x0e7f {
// Thai
return true
}
return false
}
func IsGeorgian(r rune) bool {
if 0x10a0 <= r && r <= 0x10ff {
// Georgian
return true
}
if 0x1c90 <= r && r <= 0x1cbf {
// Georgian Extended
return true
}
if 0x2d00 <= r && r <= 0x2d2f {
// Georgian Supplement
return true
}
return false
}
func IsOgham(r rune) bool {
if 0x1680 <= r && r <= 0x169f {
// Ogham
return true
}
return false
}
func IsRunic(r rune) bool {
if 0x16A0 <= r && r <= 0x16FF {
// Runic
return true
}
return false
}
func IsGeneralPunctuation(r rune) bool {
if 0x2000 <= r && r <= 0x206f {
return true
}
return false
}
func IsSupplementalPunctuation(r rune) bool {
if 0x2e00 <= r && r <= 0x2e7f {
return true
}
return false
}
func IsCJKUnifiedIdeograph(r rune) bool {
// CJK Unified Ideographs
if 0x4E00 <= r && r <= 0x9FFF {
return true
}
// CJK Unified Ideographs Extension A
if 0x3400 <= r && r <= 0x4DBF {
return true
}
return false
}