else | else | ||||
{ | { | ||||
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n"); | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } |
else | else | ||||
{ | { | ||||
for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n"); | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } |
else | else | ||||
{ | { | ||||
for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %id %ix %is %iu %il\n"); | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } |
for codepoint in data['CodePoint']: | for codepoint in data['CodePoint']: | ||||
unicode_chars[codepoint] = data | unicode_chars[codepoint] = data | ||||
def isdigit(data): | |||||
return 1 if data['CodePoint'].char() in '0123456789' else 0 | |||||
def isxdigit(data): | |||||
return 1 if data['CodePoint'].char() in '0123456789ABCDEFabcdef' else 0 | |||||
def isspace(data): | def isspace(data): | ||||
return data.get('White_Space', 0) | return data.get('White_Space', 0) | ||||
try: | try: | ||||
data = unicode_chars[codepoint] | data = unicode_chars[codepoint] | ||||
except KeyError: | except KeyError: | ||||
data = {} | |||||
data = {'CodePoint': codepoint} | |||||
script = data.get('Script', 'Zzzz') | script = data.get('Script', 'Zzzz') | ||||
title = data.get('TitleCase', codepoint) | title = data.get('TitleCase', codepoint) | ||||
upper = data.get('UpperCase', codepoint) | upper = data.get('UpperCase', codepoint) | ||||
if title == null: title = codepoint | if title == null: title = codepoint | ||||
if upper == null: upper = codepoint | if upper == null: upper = codepoint | ||||
if lower == null: lower = codepoint | if lower == null: lower = codepoint | ||||
print('%s %s %s %s %s %s %s %s %s %s' % ( | |||||
print('%s %s %s %s %s %s %s %s %s %s %s %s' % ( | |||||
codepoint, script, | codepoint, script, | ||||
data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), | data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), | ||||
upper, lower, title, | upper, lower, title, | ||||
isdigit(data), isxdigit(data), | |||||
isspace(data), | isspace(data), | ||||
isupper(data), islower(data))) | isupper(data), islower(data))) |
def __lt__(self, other): | def __lt__(self, other): | ||||
return self.codepoint < other.codepoint | return self.codepoint < other.codepoint | ||||
def char(self): | |||||
return unichr(self.codepoint) | |||||
class CodeRange: | class CodeRange: | ||||
def __init__(self, x): | def __init__(self, x): | ||||
f, l = x.split('..') | f, l = x.split('..') | ||||
def size(self): | def size(self): | ||||
return self.last.codepoint - self.first.codepoint + 1 | return self.last.codepoint - self.first.codepoint + 1 | ||||
def char(self): | |||||
return unichr(self.first.codepoint) | |||||
def codepoint(x): | def codepoint(x): | ||||
if '..' in x[0]: | if '..' in x[0]: | ||||
return CodeRange(x[0]), x[1:] | return CodeRange(x[0]), x[1:] |