forked from pyfa-org/Pyfa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cjk.py
27 lines (25 loc) · 742 Bytes
/
cjk.py
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
def isCharCjk(char):
# https://stackoverflow.com/questions/1366068/whats-the-complete-range-for-chinese-characters-in-unicode
ranges = (
('\u4e00', '\u9fff'),
('\u3400', '\u4dbf'),
('\u20000', '\u2a6df'),
('\u2a700', '\u2b73f'),
('\u2b740', '\u2b81f'),
('\u2b820', '\u2ceaf'),
('\uf900', '\ufaff'),
('\u2f800', '\u2fa1f'),
('\uac00', '\ud7af'))
for low, high in ranges:
if low <= char <= high:
return True
return False
def isStringCjk(string):
checked = set()
for char in string:
if char in checked:
continue
checked.add(char)
if isCharCjk(char):
return True
return False