## 9.0.0.1 - (In Progress) | ## 9.0.0.1 - (In Progress) | ||||
* Add `iswblank` and `iswxdigit` compatibility. | * Add `iswblank` and `iswxdigit` compatibility. | ||||
* Improve ctype compatibility. | |||||
## 9.0.0 - 2016-12-28 | ## 9.0.0 - 2016-12-28 | ||||
int ucd_islower(codepoint_t c) | int ucd_islower(codepoint_t c) | ||||
{ | { | ||||
return ucd_lookup_category(c) == UCD_CATEGORY_Ll; | |||||
return ucd_lookup_category(c) == UCD_CATEGORY_Ll | |||||
|| ucd_toupper(c) != c; | |||||
} | } | ||||
int ucd_isprint(codepoint_t c) | int ucd_isprint(codepoint_t c) | ||||
int ucd_isupper(codepoint_t c) | int ucd_isupper(codepoint_t c) | ||||
{ | { | ||||
return ucd_lookup_category(c) == UCD_CATEGORY_Lu; | |||||
return ucd_lookup_category(c) == UCD_CATEGORY_Lu | |||||
|| ucd_tolower(c) != c; | |||||
} | } | ||||
int ucd_isxdigit(codepoint_t c) | int ucd_isxdigit(codepoint_t c) |
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\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %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\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %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\n"); | |||||
uprintf(stdout, c, format ? format : "%pH %s %C %c %UH %LH %TH %is %iu %il\n"); | |||||
} | } | ||||
return 0; | return 0; | ||||
} | } |
ucd_rootdir = sys.argv[1] | ucd_rootdir = sys.argv[1] | ||||
csur_rootdir = 'data/csur' | csur_rootdir = 'data/csur' | ||||
null = ucd.CodePoint('0000') | |||||
unicode_chars = {} | unicode_chars = {} | ||||
for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): | for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): | ||||
for codepoint in data['CodePoint']: | for codepoint in data['CodePoint']: | ||||
def isspace(data): | def isspace(data): | ||||
return data.get('White_Space', 0) | return data.get('White_Space', 0) | ||||
null = ucd.CodePoint('0000') | |||||
def isupper(data): | |||||
if data.get('LowerCase', null) != null: | |||||
return 1 | |||||
elif data.get('GeneralCategory', 'Cn') == 'Lu': | |||||
return 1 | |||||
else: | |||||
return 0 | |||||
def islower(data): | |||||
if data.get('UpperCase', null) != null: | |||||
return 1 | |||||
elif data.get('GeneralCategory', 'Cn') == 'Ll': | |||||
return 1 | |||||
else: | |||||
return 0 | |||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
for codepoint in ucd.CodeRange('000000..10FFFF'): | for codepoint in ucd.CodeRange('000000..10FFFF'): | ||||
try: | try: | ||||
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' % ( | |||||
print('%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, | ||||
isspace(data))) | |||||
isspace(data), | |||||
isupper(data), islower(data))) |