Start searching from 1 char if strin contains CJK glyphs

This commit is contained in:
DarkPhoenix
2019-06-05 19:06:17 +03:00
parent 41b72c2789
commit e77ada4e8c
2 changed files with 29 additions and 3 deletions

23
utils/cjk.py Normal file
View File

@@ -0,0 +1,23 @@
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):
for char in string:
if isCharCjk(char):
return True
return False