| 1 | const std = @import("std"); |
| 2 | const icu = @import("icu"); |
| 3 | |
| 4 | const t = @import("./types.zig"); |
| 5 | |
| 6 | // |
| 7 | // uchar.h |
| 8 | |
| 9 | // U_CAPI UBool U_EXPORT2 |
| 10 | // u_hasBinaryProperty(UChar32 c, UProperty which); |
| 11 | export fn u_hasBinaryProperty(cp: u32, prop: t.UProperty) bool { |
| 12 | return switch (prop) { |
| 13 | .UCHAR_ALPHABETIC => icu.hasDerivedCoreProperty(cp, .Alphabetic), |
| 14 | .UCHAR_ASCII_HEX_DIGIT => icu.hasProperty(cp, .ASCII_Hex_Digit), |
| 15 | .UCHAR_BIDI_CONTROL => icu.hasProperty(cp, .Bidi_Control), |
| 16 | .UCHAR_BIDI_MIRRORED => false, // TODO: |
| 17 | .UCHAR_DASH => icu.hasProperty(cp, .Dash), |
| 18 | .UCHAR_DEFAULT_IGNORABLE_CODE_POINT => icu.hasDerivedCoreProperty(cp, .Default_Ignorable_Code_Point), |
| 19 | .UCHAR_DEPRECATED => icu.hasProperty(cp, .Deprecated), |
| 20 | .UCHAR_DIACRITIC => icu.hasProperty(cp, .Diacritic), |
| 21 | .UCHAR_EXTENDER => icu.hasProperty(cp, .Extender), |
| 22 | .UCHAR_FULL_COMPOSITION_EXCLUSION => false, // TODO: |
| 23 | .UCHAR_GRAPHEME_BASE => icu.hasDerivedCoreProperty(cp, .Grapheme_Base), |
| 24 | .UCHAR_GRAPHEME_EXTEND => icu.hasDerivedCoreProperty(cp, .Grapheme_Extend), |
| 25 | .UCHAR_GRAPHEME_LINK => icu.hasDerivedCoreProperty(cp, .Grapheme_Link), |
| 26 | .UCHAR_HEX_DIGIT => icu.hasProperty(cp, .Hex_Digit), |
| 27 | .UCHAR_HYPHEN => icu.hasProperty(cp, .Hyphen), |
| 28 | .UCHAR_ID_CONTINUE => icu.hasDerivedCoreProperty(cp, .ID_Continue), |
| 29 | .UCHAR_ID_START => icu.hasDerivedCoreProperty(cp, .ID_Start), |
| 30 | .UCHAR_IDEOGRAPHIC => icu.hasProperty(cp, .Ideographic), |
| 31 | .UCHAR_IDS_BINARY_OPERATOR => icu.hasProperty(cp, .IDS_Binary_Operator), |
| 32 | .UCHAR_IDS_TRINARY_OPERATOR => icu.hasProperty(cp, .IDS_Trinary_Operator), |
| 33 | .UCHAR_JOIN_CONTROL => icu.hasProperty(cp, .Join_Control), |
| 34 | .UCHAR_LOGICAL_ORDER_EXCEPTION => icu.hasProperty(cp, .Logical_Order_Exception), |
| 35 | .UCHAR_LOWERCASE => icu.hasDerivedCoreProperty(cp, .Lowercase), |
| 36 | .UCHAR_MATH => icu.hasDerivedCoreProperty(cp, .Math), |
| 37 | .UCHAR_NONCHARACTER_CODE_POINT => icu.hasProperty(cp, .Noncharacter_Code_Point), |
| 38 | .UCHAR_QUOTATION_MARK => icu.hasProperty(cp, .Quotation_Mark), |
| 39 | .UCHAR_RADICAL => icu.hasProperty(cp, .Radical), |
| 40 | .UCHAR_SOFT_DOTTED => icu.hasProperty(cp, .Soft_Dotted), |
| 41 | .UCHAR_TERMINAL_PUNCTUATION => icu.hasProperty(cp, .Terminal_Punctuation), |
| 42 | .UCHAR_UNIFIED_IDEOGRAPH => icu.hasProperty(cp, .Unified_Ideograph), |
| 43 | .UCHAR_UPPERCASE => icu.hasDerivedCoreProperty(cp, .Uppercase), |
| 44 | .UCHAR_WHITE_SPACE => icu.hasProperty(cp, .White_Space), |
| 45 | .UCHAR_XID_CONTINUE => icu.hasDerivedCoreProperty(cp, .XID_Continue), |
| 46 | .UCHAR_XID_START => icu.hasDerivedCoreProperty(cp, .XID_Start), |
| 47 | .UCHAR_CASE_SENSITIVE => false, // TODO: |
| 48 | .UCHAR_S_TERM => false, // TODO: |
| 49 | .UCHAR_VARIATION_SELECTOR => false, // TODO: |
| 50 | .UCHAR_NFD_INERT => false, // TODO: |
| 51 | .UCHAR_NFKD_INERT => false, // TODO: |
| 52 | .UCHAR_NFC_INERT => false, // TODO: |
| 53 | .UCHAR_NFKC_INERT => false, // TODO: |
| 54 | .UCHAR_SEGMENT_STARTER => false, // TODO: |
| 55 | .UCHAR_PATTERN_SYNTAX => false, // TODO: |
| 56 | .UCHAR_PATTERN_WHITE_SPACE => false, // TODO: |
| 57 | .UCHAR_POSIX_ALNUM => false, // TODO: |
| 58 | .UCHAR_POSIX_BLANK => false, // TODO: |
| 59 | .UCHAR_POSIX_GRAPH => false, // TODO: |
| 60 | .UCHAR_POSIX_PRINT => false, // TODO: |
| 61 | .UCHAR_POSIX_XDIGIT => false, // TODO: |
| 62 | .UCHAR_CASED => icu.hasDerivedCoreProperty(cp, .Cased), |
| 63 | .UCHAR_CASE_IGNORABLE => icu.hasDerivedCoreProperty(cp, .Case_Ignorable), |
| 64 | .UCHAR_CHANGES_WHEN_LOWERCASED => icu.hasDerivedCoreProperty(cp, .Changes_When_Lowercased), |
| 65 | .UCHAR_CHANGES_WHEN_UPPERCASED => icu.hasDerivedCoreProperty(cp, .Changes_When_Uppercased), |
| 66 | .UCHAR_CHANGES_WHEN_TITLECASED => icu.hasDerivedCoreProperty(cp, .Changes_When_Titlecased), |
| 67 | .UCHAR_CHANGES_WHEN_CASEFOLDED => icu.hasDerivedCoreProperty(cp, .Changes_When_Casefolded), |
| 68 | .UCHAR_CHANGES_WHEN_CASEMAPPED => icu.hasDerivedCoreProperty(cp, .Changes_When_Casemapped), |
| 69 | .UCHAR_CHANGES_WHEN_NFKC_CASEFOLDED => false, // TODO: |
| 70 | .UCHAR_EMOJI => icu.hasEmojiCategory(cp, .Emoji), |
| 71 | .UCHAR_EMOJI_PRESENTATION => icu.hasEmojiCategory(cp, .Emoji_Presentation), |
| 72 | .UCHAR_EMOJI_MODIFIER => icu.hasEmojiCategory(cp, .Emoji_Modifier), |
| 73 | .UCHAR_EMOJI_MODIFIER_BASE => icu.hasEmojiCategory(cp, .Emoji_Modifier_Base), |
| 74 | .UCHAR_EMOJI_COMPONENT => icu.hasEmojiCategory(cp, .Emoji_Component), |
| 75 | .UCHAR_REGIONAL_INDICATOR => icu.hasProperty(cp, .Regional_Indicator), |
| 76 | .UCHAR_PREPENDED_CONCATENATION_MARK => false, // TODO: |
| 77 | .UCHAR_EXTENDED_PICTOGRAPHIC => icu.hasEmojiCategory(cp, .Extended_Pictographic), |
| 78 | .UCHAR_BASIC_EMOJI => false, // TODO: |
| 79 | .UCHAR_EMOJI_KEYCAP_SEQUENCE => false, // TODO: |
| 80 | .UCHAR_RGI_EMOJI_MODIFIER_SEQUENCE => false, // TODO: |
| 81 | .UCHAR_RGI_EMOJI_FLAG_SEQUENCE => false, // TODO: |
| 82 | .UCHAR_RGI_EMOJI_TAG_SEQUENCE => false, // TODO: |
| 83 | .UCHAR_RGI_EMOJI_ZWJ_SEQUENCE => false, // TODO: |
| 84 | .UCHAR_RGI_EMOJI => false, // TODO: |
| 85 | .UCHAR_IDS_UNARY_OPERATOR => false, // TODO: |
| 86 | .UCHAR_ID_COMPAT_MATH_START => icu.hasProperty(cp, .ID_Compat_Math_Start), |
| 87 | .UCHAR_ID_COMPAT_MATH_CONTINUE => icu.hasProperty(cp, .ID_Compat_Math_Continue), |
| 88 | .UCHAR_BIDI_CLASS => false, // TODO: |
| 89 | .UCHAR_BLOCK => false, // TODO: |
| 90 | .UCHAR_CANONICAL_COMBINING_CLASS => false, // TODO: |
| 91 | .UCHAR_DECOMPOSITION_TYPE => false, // TODO: |
| 92 | .UCHAR_EAST_ASIAN_WIDTH => icu.eastAsianWidth(cp) != null, |
| 93 | .UCHAR_GENERAL_CATEGORY => false, // TODO: |
| 94 | .UCHAR_JOINING_GROUP => false, // TODO: |
| 95 | .UCHAR_JOINING_TYPE => false, // TODO: |
| 96 | .UCHAR_LINE_BREAK => false, // TODO: |
| 97 | .UCHAR_NUMERIC_TYPE => false, // TODO: |
| 98 | .UCHAR_SCRIPT => false, // TODO: |
| 99 | .UCHAR_HANGUL_SYLLABLE_TYPE => false, // TODO: |
| 100 | .UCHAR_NFD_QUICK_CHECK => false, // TODO: |
| 101 | .UCHAR_NFKD_QUICK_CHECK => false, // TODO: |
| 102 | .UCHAR_NFC_QUICK_CHECK => false, // TODO: |
| 103 | .UCHAR_NFKC_QUICK_CHECK => false, // TODO: |
| 104 | .UCHAR_LEAD_CANONICAL_COMBINING_CLASS => false, // TODO: |
| 105 | .UCHAR_TRAIL_CANONICAL_COMBINING_CLASS => false, // TODO: |
| 106 | .UCHAR_GRAPHEME_CLUSTER_BREAK => false, // TODO: |
| 107 | .UCHAR_SENTENCE_BREAK => false, // TODO: |
| 108 | .UCHAR_WORD_BREAK => false, // TODO: |
| 109 | .UCHAR_BIDI_PAIRED_BRACKET_TYPE => icu.bidiPairedBracketType(cp) != null, |
| 110 | .UCHAR_INDIC_POSITIONAL_CATEGORY => false, // TODO: |
| 111 | .UCHAR_INDIC_SYLLABIC_CATEGORY => false, // TODO: |
| 112 | .UCHAR_VERTICAL_ORIENTATION => false, // TODO: |
| 113 | .UCHAR_GENERAL_CATEGORY_MASK => false, // TODO: |
| 114 | .UCHAR_NUMERIC_VALUE => false, // TODO: |
| 115 | .UCHAR_AGE => @as(u16, @bitCast(icu.age(cp))) > 0, |
| 116 | .UCHAR_BIDI_MIRRORING_GLYPH => false, // TODO: |
| 117 | .UCHAR_CASE_FOLDING => false, // TODO: |
| 118 | .UCHAR_LOWERCASE_MAPPING => false, // TODO: |
| 119 | .UCHAR_NAME => false, // TODO: |
| 120 | .UCHAR_SIMPLE_CASE_FOLDING => false, // TODO: |
| 121 | .UCHAR_SIMPLE_LOWERCASE_MAPPING => false, // TODO: |
| 122 | .UCHAR_SIMPLE_TITLECASE_MAPPING => false, // TODO: |
| 123 | .UCHAR_SIMPLE_UPPERCASE_MAPPING => false, // TODO: |
| 124 | .UCHAR_TITLECASE_MAPPING => false, // TODO: |
| 125 | .UCHAR_UPPERCASE_MAPPING => false, // TODO: |
| 126 | .UCHAR_BIDI_PAIRED_BRACKET => false, // TODO: |
| 127 | .UCHAR_SCRIPT_EXTENSIONS => false, // TODO: |
| 128 | _ => false, |
| 129 | |
| 130 | // InCB, |
| 131 | |
| 132 | // Other_Math, |
| 133 | // Other_Alphabetic, |
| 134 | // Other_Lowercase, |
| 135 | // Other_Uppercase, |
| 136 | // Other_Grapheme_Extend, |
| 137 | // Other_Default_Ignorable_Code_Point, |
| 138 | // Other_ID_Start, |
| 139 | // Other_ID_Continue, |
| 140 | // Sentence_Terminal, |
| 141 | // Variation_Selector, |
| 142 | // Pattern_White_Space, |
| 143 | // Pattern_Syntax, |
| 144 | // Prepended_Concatenation_Mark, |
| 145 | // IDS_Unary_Operator, |
| 146 | // Modifier_Combining_Mark, |
| 147 | }; |
| 148 | } |
| 149 | |
| 150 | // U_CAPI UBool U_EXPORT2 |
| 151 | // u_stringHasBinaryProperty(const UChar *s, int32_t length, UProperty which); |
| 152 | |
| 153 | // U_CAPI const USet * U_EXPORT2 |
| 154 | // u_getBinaryPropertySet(UProperty property, UErrorCode *pErrorCode); |
| 155 | |
| 156 | // U_CAPI UBool U_EXPORT2 |
| 157 | // u_isUAlphabetic(UChar32 c); |
| 158 | |
| 159 | // U_CAPI UBool U_EXPORT2 |
| 160 | // u_isULowercase(UChar32 c); |
| 161 | |
| 162 | // U_CAPI UBool U_EXPORT2 |
| 163 | // u_isUUppercase(UChar32 c); |
| 164 | |
| 165 | // U_CAPI UBool U_EXPORT2 |
| 166 | // u_isUWhiteSpace(UChar32 c); |
| 167 | |
| 168 | // U_CAPI int32_t U_EXPORT2 |
| 169 | // u_getIntPropertyValue(UChar32 c, UProperty which); |
| 170 | |
| 171 | // U_CAPI int32_t U_EXPORT2 |
| 172 | // u_getIntPropertyMinValue(UProperty which); |
| 173 | |
| 174 | // U_CAPI int32_t U_EXPORT2 |
| 175 | // u_getIntPropertyMaxValue(UProperty which); |
| 176 | |
| 177 | // U_CAPI const UCPMap * U_EXPORT2 |
| 178 | // u_getIntPropertyMap(UProperty property, UErrorCode *pErrorCode); |
| 179 | |
| 180 | // U_CAPI double U_EXPORT2 |
| 181 | // u_getNumericValue(UChar32 c); |
| 182 | |
| 183 | // U_CAPI UBool U_EXPORT2 |
| 184 | // u_islower(UChar32 c); |
| 185 | |
| 186 | // U_CAPI UBool U_EXPORT2 |
| 187 | // u_isupper(UChar32 c); |
| 188 | |
| 189 | // U_CAPI UBool U_EXPORT2 |
| 190 | // u_istitle(UChar32 c); |
| 191 | |
| 192 | // U_CAPI UBool U_EXPORT2 |
| 193 | // u_isdigit(UChar32 c); |
| 194 | |
| 195 | // U_CAPI UBool U_EXPORT2 |
| 196 | // u_isalpha(UChar32 c); |
| 197 | |
| 198 | // U_CAPI UBool U_EXPORT2 |
| 199 | // u_isalnum(UChar32 c); |
| 200 | |
| 201 | // U_CAPI UBool U_EXPORT2 |
| 202 | // u_isxdigit(UChar32 c); |
| 203 | |
| 204 | // U_CAPI UBool U_EXPORT2 |
| 205 | // u_ispunct(UChar32 c); |
| 206 | |
| 207 | // U_CAPI UBool U_EXPORT2 |
| 208 | // u_isgraph(UChar32 c); |
| 209 | |
| 210 | // U_CAPI UBool U_EXPORT2 |
| 211 | // u_isblank(UChar32 c); |
| 212 | // U_CAPI UBool U_EXPORT2 |
| 213 | // u_isdefined(UChar32 c); |
| 214 | |
| 215 | // U_CAPI UBool U_EXPORT2 |
| 216 | // u_isspace(UChar32 c); |
| 217 | |
| 218 | // U_CAPI UBool U_EXPORT2 |
| 219 | // u_isJavaSpaceChar(UChar32 c); |
| 220 | |
| 221 | // U_CAPI UBool U_EXPORT2 |
| 222 | // u_isWhitespace(UChar32 c); |
| 223 | |
| 224 | // U_CAPI UBool U_EXPORT2 |
| 225 | // u_iscntrl(UChar32 c); |
| 226 | |
| 227 | // U_CAPI UBool U_EXPORT2 |
| 228 | // u_isISOControl(UChar32 c); |
| 229 | |
| 230 | // U_CAPI UBool U_EXPORT2 |
| 231 | // u_isprint(UChar32 c); |
| 232 | |
| 233 | // U_CAPI UBool U_EXPORT2 |
| 234 | // u_isbase(UChar32 c); |
| 235 | |
| 236 | // U_CAPI UCharDirection U_EXPORT2 |
| 237 | // u_charDirection(UChar32 c); |
| 238 | |
| 239 | // U_CAPI UBool U_EXPORT2 |
| 240 | // u_isMirrored(UChar32 c); |
| 241 | |
| 242 | // U_CAPI UChar32 U_EXPORT2 |
| 243 | // u_charMirror(UChar32 c); |
| 244 | |
| 245 | // U_CAPI UChar32 U_EXPORT2 |
| 246 | // u_getBidiPairedBracket(UChar32 c); |
| 247 | |
| 248 | // U_CAPI int8_t U_EXPORT2 |
| 249 | // u_charType(UChar32 c); |
| 250 | |
| 251 | // U_CAPI void U_EXPORT2 |
| 252 | // u_enumCharTypes(UCharEnumTypeRange *enumRange, const void *context); |
| 253 | |
| 254 | // U_CAPI uint8_t U_EXPORT2 |
| 255 | // u_getCombiningClass(UChar32 c); |
| 256 | |
| 257 | // U_CAPI int32_t U_EXPORT2 |
| 258 | // u_charDigitValue(UChar32 c); |
| 259 | |
| 260 | // U_CAPI UBlockCode U_EXPORT2 |
| 261 | // ublock_getCode(UChar32 c); |
| 262 | |
| 263 | // U_CAPI int32_t U_EXPORT2 |
| 264 | // u_charName(UChar32 code, UCharNameChoice nameChoice, char *buffer, int32_t bufferLength, UErrorCode *pErrorCode); |
| 265 | |
| 266 | // U_CAPI UChar32 U_EXPORT2 |
| 267 | // u_charFromName(UCharNameChoice nameChoice, const char *name, UErrorCode *pErrorCode); |
| 268 | |
| 269 | // U_CAPI void U_EXPORT2 |
| 270 | // u_enumCharNames(UChar32 start, UChar32 limit, UEnumCharNamesFn *fn, void *context, UCharNameChoice nameChoice, UErrorCode *pErrorCode); |
| 271 | |
| 272 | // U_CAPI const char* U_EXPORT2 |
| 273 | // u_getPropertyName(UProperty property, UPropertyNameChoice nameChoice); |
| 274 | |
| 275 | // U_CAPI UProperty U_EXPORT2 |
| 276 | // u_getPropertyEnum(const char* alias); |
| 277 | |
| 278 | // U_CAPI const char* U_EXPORT2 |
| 279 | // u_getPropertyValueName(UProperty property, int32_t value, UPropertyNameChoice nameChoice); |
| 280 | |
| 281 | // U_CAPI int32_t U_EXPORT2 |
| 282 | // u_getPropertyValueEnum(UProperty property, const char* alias); |
| 283 | |
| 284 | // U_CAPI UBool U_EXPORT2 |
| 285 | // u_isIDStart(UChar32 c); |
| 286 | |
| 287 | // U_CAPI UBool U_EXPORT2 |
| 288 | // u_isIDPart(UChar32 c); |
| 289 | |
| 290 | // U_CAPI bool U_EXPORT2 |
| 291 | // u_hasIDType(UChar32 c, UIdentifierType type); |
| 292 | |
| 293 | // U_CAPI int32_t U_EXPORT2 |
| 294 | // u_getIDTypes(UChar32 c, UIdentifierType *types, int32_t capacity, UErrorCode *pErrorCode); |
| 295 | |
| 296 | // U_CAPI UBool U_EXPORT2 |
| 297 | // u_isIDIgnorable(UChar32 c); |
| 298 | |
| 299 | // U_CAPI UBool U_EXPORT2 |
| 300 | // u_isJavaIDStart(UChar32 c); |
| 301 | |
| 302 | // U_CAPI UBool U_EXPORT2 |
| 303 | // u_isJavaIDPart(UChar32 c); |
| 304 | |
| 305 | // U_CAPI UChar32 U_EXPORT2 |
| 306 | // u_tolower(UChar32 c); |
| 307 | |
| 308 | // U_CAPI UChar32 U_EXPORT2 |
| 309 | // u_toupper(UChar32 c); |
| 310 | |
| 311 | // U_CAPI UChar32 U_EXPORT2 |
| 312 | // u_totitle(UChar32 c); |
| 313 | |
| 314 | // U_CAPI UChar32 U_EXPORT2 |
| 315 | // u_foldCase(UChar32 c, uint32_t options); |
| 316 | |
| 317 | // U_CAPI int32_t U_EXPORT2 |
| 318 | // u_digit(UChar32 ch, int8_t radix); |
| 319 | |
| 320 | // U_CAPI UChar32 U_EXPORT2 |
| 321 | // u_forDigit(int32_t digit, int8_t radix); |
| 322 | |
| 323 | // U_CAPI void U_EXPORT2 |
| 324 | // u_charAge(UChar32 c, UVersionInfo versionArray); |
| 325 | |
| 326 | // U_CAPI void U_EXPORT2 |
| 327 | // u_getUnicodeVersion(UVersionInfo versionArray); |
| 328 | |
| 329 | // U_CAPI int32_t U_EXPORT2 |
| 330 | // u_getFC_NFKC_Closure(UChar32 c, UChar *dest, int32_t destCapacity, UErrorCode *pErrorCode); |