| UCD_PROPERTY_JOIN_CONTROL = 0x00000008, /**< @brief Join_Control */ | UCD_PROPERTY_JOIN_CONTROL = 0x00000008, /**< @brief Join_Control */ | ||||
| UCD_PROPERTY_DASH = 0x00000010, /**< @brief Dash */ | UCD_PROPERTY_DASH = 0x00000010, /**< @brief Dash */ | ||||
| UCD_PROPERTY_HYPHEN = 0x00000020, /**< @brief Hyphen */ | UCD_PROPERTY_HYPHEN = 0x00000020, /**< @brief Hyphen */ | ||||
| UCD_PROPERTY_QUOTATION_MARK = 0x00000020, /**< @brief Quotation_Mark */ | UCD_PROPERTY_QUOTATION_MARK = 0x00000040, /**< @brief Quotation_Mark */ | ||||
| } ucd_property; | } ucd_property; | ||||
| /** @brief Return the properties of the specified codepoint. | /** @brief Return the properties of the specified codepoint. |
| case 'p': // codepoint | case 'p': // codepoint | ||||
| uprintf_codepoint(out, c, *++format); | uprintf_codepoint(out, c, *++format); | ||||
| break; | break; | ||||
| case 'P': // properties | |||||
| fprintf(out, "%08x", ucd_properties(c, ucd_lookup_category(c))); | |||||
| break; | |||||
| case 'i': // is* | case 'i': // is* | ||||
| uprintf_is(out, c, *++format); | uprintf_is(out, c, *++format); | ||||
| break; | break; | ||||
| { | { | ||||
| for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
| uprintf(stdout, c, format ? format : | uprintf(stdout, c, format ? format : | ||||
| "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n"); | "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il %P\n"); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } |
| case 'p': // codepoint | case 'p': // codepoint | ||||
| uprintf_codepoint(out, c, *++format); | uprintf_codepoint(out, c, *++format); | ||||
| break; | break; | ||||
| case 'P': // properties | |||||
| fprintf(out, "%08x", ucd_properties(c, ucd_lookup_category(c))); | |||||
| break; | |||||
| case 'i': // is* | case 'i': // is* | ||||
| uprintf_is(out, c, *++format); | uprintf_is(out, c, *++format); | ||||
| break; | break; | ||||
| { | { | ||||
| for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
| uprintf(stdout, c, format ? format : | uprintf(stdout, c, format ? format : | ||||
| "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n"); | "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il %P\n"); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } |
| case 'p': // codepoint | case 'p': // codepoint | ||||
| uprintf_codepoint(out, c, *++format); | uprintf_codepoint(out, c, *++format); | ||||
| break; | break; | ||||
| case 'P': // properties | |||||
| fprintf(out, "%08x", ucd::properties(c, ucd::lookup_category(c))); | |||||
| break; | |||||
| case 'i': // is* | case 'i': // is* | ||||
| uprintf_is(out, c, *++format); | uprintf_is(out, c, *++format); | ||||
| break; | break; | ||||
| { | { | ||||
| for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) | for (ucd::codepoint_t c = 0; c <= 0x10FFFF; ++c) | ||||
| uprintf(stdout, c, format ? format : | uprintf(stdout, c, format ? format : | ||||
| "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il\n"); | "%pH %s %C %c %UH %LH %TH %id %ix %ic %is %ib %ip %iP %ig %iA %ia %iu %il %P\n"); | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } |
| else: | else: | ||||
| return 0 | return 0 | ||||
| def decomposition_type(data, dtype): | |||||
| value = data.get('DecompositionType', None) | |||||
| if value and value.startswith(dtype): | |||||
| return value | |||||
| return None | |||||
| def properties(data): | |||||
| props = 0 | |||||
| props += 1 * data.get('White_Space', 0) | |||||
| props += 2 * (decomposition_type(data, '<noBreak>') != None) | |||||
| props += 4 * data.get('Bidi_Control', 0) | |||||
| props += 8 * data.get('Join_Control', 0) | |||||
| props += 16 * data.get('Dash', 0) | |||||
| props += 32 * data.get('Hyphen', 0) | |||||
| props += 64 * data.get('Quotation_Mark', 0) | |||||
| return props | |||||
| 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 %s %s %s %s %s %s %s %s %s %s %s' % ( | print('%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %08x' % ( | ||||
| 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), | isdigit(data), isxdigit(data), | ||||
| iscntrl(data), isspace(data), isblank(data), ispunct(data), | iscntrl(data), isspace(data), isblank(data), ispunct(data), | ||||
| isprint(data), isgraph(data), isalnum(data), isalpha(data), isupper(data), islower(data))) | isprint(data), isgraph(data), isalnum(data), isalpha(data), isupper(data), islower(data), | ||||
| properties(data))) |