diff --git a/CHANGELOG.md b/CHANGELOG.md index 26289ca2..0612bb58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 9.0.0.1 - (In Progress) * Add `iswblank` and `iswxdigit` compatibility. +* Improve ctype compatibility. ## 9.0.0 - 2016-12-28 diff --git a/src/ctype.c b/src/ctype.c index 91aaaff6..9f9b91b9 100644 --- a/src/ctype.c +++ b/src/ctype.c @@ -97,7 +97,8 @@ int ucd_isgraph(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) @@ -159,7 +160,8 @@ int ucd_isspace(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) diff --git a/tests/printcdata.c b/tests/printcdata.c index 21f668b9..6f59f453 100644 --- a/tests/printcdata.c +++ b/tests/printcdata.c @@ -248,7 +248,7 @@ int main(int argc, char **argv) else { 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; } diff --git a/tests/printucddata.c b/tests/printucddata.c index 47086c52..136d88ee 100644 --- a/tests/printucddata.c +++ b/tests/printucddata.c @@ -243,7 +243,7 @@ int main(int argc, char **argv) else { 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; } diff --git a/tests/printucddata_cpp.cpp b/tests/printucddata_cpp.cpp index 8bc8fc71..c19c4fbf 100644 --- a/tests/printucddata_cpp.cpp +++ b/tests/printucddata_cpp.cpp @@ -243,7 +243,7 @@ int main(int argc, char **argv) else { 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; } diff --git a/tools/printdata.py b/tools/printdata.py index 7c49c892..fd1eb236 100755 --- a/tools/printdata.py +++ b/tools/printdata.py @@ -24,6 +24,8 @@ import ucd ucd_rootdir = sys.argv[1] csur_rootdir = 'data/csur' +null = ucd.CodePoint('0000') + unicode_chars = {} for data in ucd.parse_ucd_data(ucd_rootdir, 'UnicodeData'): for codepoint in data['CodePoint']: @@ -44,7 +46,22 @@ if '--with-csur' in sys.argv: def isspace(data): 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__': for codepoint in ucd.CodeRange('000000..10FFFF'): try: @@ -58,8 +75,9 @@ if __name__ == '__main__': if title == null: title = codepoint if upper == null: upper = 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, data.get('GeneralCategory', 'Cn')[0], data.get('GeneralCategory', 'Cn'), upper, lower, title, - isspace(data))) + isspace(data), + isupper(data), islower(data)))