diff --git a/kotlin-native/backend.native/tests/runtime/text/trim.kt b/kotlin-native/backend.native/tests/runtime/text/trim.kt index 0fd5c149139..9b61a870769 100644 --- a/kotlin-native/backend.native/tests/runtime/text/trim.kt +++ b/kotlin-native/backend.native/tests/runtime/text/trim.kt @@ -48,7 +48,7 @@ private fun trimWhitespaces() { assertEquals(expected = "String", actual = "\u0020 \u202FString\u2028\u2029".trim(), message = "Trim special whitespaces") - assertEquals(expected = "\u1FFFString", actual = "\u0085 \u1FFFString".trim(), + assertEquals(expected = "\u1FFFString", actual = "\u00A0 \u1FFFString".trim(), message = "Trim special whitespace but should left a unicode symbol") assertEquals(expected = "String\tSTR", actual = " \nString\tSTR ".trim(), message = "Trim newline") } diff --git a/kotlin-native/runtime/generator/build.gradle b/kotlin-native/runtime/generator/build.gradle index e5d2cfe32b8..33a21a1af2b 100644 --- a/kotlin-native/runtime/generator/build.gradle +++ b/kotlin-native/runtime/generator/build.gradle @@ -17,4 +17,11 @@ task run(type: JavaExec) { main 'generators.GenerateStandardLibKt' classpath configurations.generatorRuntime args = ["native", "${project(":runtime").projectDir}/src/main/kotlin/generated"] +} + +task generateUnicodeData(type: JavaExec) { + group 'application' + main 'generators.unicode.GenerateUnicodeDataKt' + classpath configurations.generatorRuntime + args = ["native", "${project(":runtime").projectDir}/src/main/kotlin/generated"] } \ No newline at end of file diff --git a/kotlin-native/runtime/src/main/cpp/KString.cpp b/kotlin-native/runtime/src/main/cpp/KString.cpp index 3f96007b706..63b37549675 100644 --- a/kotlin-native/runtime/src/main/cpp/KString.cpp +++ b/kotlin-native/runtime/src/main/cpp/KString.cpp @@ -79,198 +79,6 @@ OBJ_GETTER(utf8ToUtf16, const char* rawString, size_t rawStringLength) { RETURN_RESULT_OF(utf8ToUtf16Impl, rawString, end, charCount); } - -// Case conversion is derived work from Apache Harmony. -// Unicode 3.0.1 (same as Unicode 3.0.0) -enum CharacterClass { - /** - * Unicode category constant Cn. - */ - UNASSIGNED = 0, - /** - * Unicode category constant Lu. - */ - UPPERCASE_LETTER = 1, - /** - * Unicode category constant Ll. - */ - LOWERCASE_LETTER = 2, - /** - * Unicode category constant Lt. - */ - TITLECASE_LETTER = 3, - /** - * Unicode category constant Lm. - */ - MODIFIER_LETTER = 4, - /** - * Unicode category constant Lo. - */ - OTHER_LETTER = 5, - /** - * Unicode category constant Mn. - */ - NON_SPACING_MARK = 6, - /** - * Unicode category constant Me. - */ - ENCLOSING_MARK = 7, - /** - * Unicode category constant Mc. - */ - COMBINING_SPACING_MARK = 8, - /** - * Unicode category constant Nd. - */ - DECIMAL_DIGIT_NUMBER = 9, - /** - * Unicode category constant Nl. - */ - LETTER_NUMBER = 10, - /** - * Unicode category constant No. - */ - OTHER_NUMBER = 11, - /** - * Unicode category constant Zs. - */ - SPACE_SEPARATOR = 12, - /** - * Unicode category constant Zl. - */ - LINE_SEPARATOR = 13, - /** - * Unicode category constant Zp. - */ - PARAGRAPH_SEPARATOR = 14, - /** - * Unicode category constant Cc. - */ - CONTROL = 15, - /** - * Unicode category constant Cf. - */ - FORMAT = 16, - /** - * Unicode category constant Co. - */ - PRIVATE_USE = 18, - /** - * Unicode category constant Cs. - */ - SURROGATE = 19, - /** - * Unicode category constant Pd. - */ - DASH_PUNCTUATION = 20, - /** - * Unicode category constant Ps. - */ - START_PUNCTUATION = 21, - /** - * Unicode category constant Pe. - */ - END_PUNCTUATION = 22, - /** - * Unicode category constant Pc. - */ - CONNECTOR_PUNCTUATION = 23, - /** - * Unicode category constant Po. - */ - OTHER_PUNCTUATION = 24, - /** - * Unicode category constant Sm. - */ - MATH_SYMBOL = 25, - /** - * Unicode category constant Sc. - */ - CURRENCY_SYMBOL = 26, - /** - * Unicode category constant Sk. - */ - MODIFIER_SYMBOL = 27, - /** - * Unicode category constant So. - */ - OTHER_SYMBOL = 28, - /** - * Unicode category constant Pi. - */ - INITIAL_QUOTE_PUNCTUATION = 29, - /** - * Unicode category constant Pf. - */ - FINAL_QUOTE_PUNCTUATION = 30 -}; - -constexpr KByte typeValuesCache[] = { - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 12, 24, 24, 24, 26, 24, 24, 24, 21, 22, 24, 25, 24, 20, 24, 24, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 24, 24, 25, 25, 25, 24, - 24, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 21, 24, 22, 27, 23, - 27, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 21, 25, 22, 25, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, - 12, 24, 26, 26, 26, 26, 28, 28, 27, 28, 2, 29, 25, 16, 28, 27, - 28, 25, 11, 11, 27, 2, 28, 24, 27, 11, 2, 30, 11, 11, 11, 24, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 25, 1, 1, 1, 1, 1, 1, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 25, 2, 2, 2, 2, 2, 2, 2, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, - 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 1, 2, 1, - 2, 1, 2, 1, 2, 1, 2, 1, 2, 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 1, 2 -}; - constexpr KShort uppercaseValuesCache[] = { 924, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, @@ -436,143 +244,6 @@ constexpr KChar digitValues[] = { 0x1819, 0x1810, 0xff19, 0xff10, 0xff3a, 0xff17, 0xff5a, 0xff37 }; -constexpr KChar typeKeys[] = { - 0x0, 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2d, 0x2f, 0x31, 0x3a, 0x3c, 0x3f, 0x41, 0x5b, 0x5d, 0x5f, 0x61, 0x7b, 0x7d, - 0x7f, 0xa0, 0xa2, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb1, 0xb3, 0xb5, 0xb7, 0xb9, 0xbb, 0xbd, 0xbf, 0xc1, 0xd7, 0xd9, 0xdf, - 0xf7, 0xf9, 0x100, 0x138, 0x149, 0x179, 0x17f, 0x181, 0x183, 0x187, 0x18a, 0x18c, 0x18e, 0x192, 0x194, 0x197, 0x199, 0x19c, 0x19e, 0x1a0, - 0x1a7, 0x1ab, 0x1af, 0x1b2, 0x1b4, 0x1b8, 0x1ba, 0x1bc, 0x1be, 0x1c0, 0x1c4, 0x1c6, 0x1c8, 0x1ca, 0x1cc, 0x1dd, 0x1f0, 0x1f2, 0x1f4, 0x1f7, - 0x1f9, 0x222, 0x250, 0x2b0, 0x2b9, 0x2bb, 0x2c2, 0x2d0, 0x2d2, 0x2e0, 0x2e5, 0x2ee, 0x300, 0x360, 0x374, 0x37a, 0x37e, 0x384, 0x386, 0x389, - 0x38c, 0x38e, 0x390, 0x392, 0x3a3, 0x3ac, 0x3d0, 0x3d2, 0x3d5, 0x3da, 0x3f0, 0x400, 0x430, 0x460, 0x482, 0x484, 0x488, 0x48c, 0x4c1, 0x4c7, - 0x4cb, 0x4d0, 0x4f8, 0x531, 0x559, 0x55b, 0x561, 0x589, 0x591, 0x5a3, 0x5bb, 0x5be, 0x5c2, 0x5d0, 0x5f0, 0x5f3, 0x60c, 0x61b, 0x61f, 0x621, - 0x640, 0x642, 0x64b, 0x660, 0x66a, 0x670, 0x672, 0x6d4, 0x6d6, 0x6dd, 0x6df, 0x6e5, 0x6e7, 0x6e9, 0x6eb, 0x6f0, 0x6fa, 0x6fd, 0x700, 0x70f, - 0x711, 0x713, 0x730, 0x780, 0x7a6, 0x901, 0x903, 0x905, 0x93c, 0x93e, 0x941, 0x949, 0x94d, 0x950, 0x952, 0x958, 0x962, 0x964, 0x966, 0x970, - 0x981, 0x983, 0x985, 0x98f, 0x993, 0x9aa, 0x9b2, 0x9b6, 0x9bc, 0x9be, 0x9c1, 0x9c7, 0x9cb, 0x9cd, 0x9d7, 0x9dc, 0x9df, 0x9e2, 0x9e6, 0x9f0, - 0x9f2, 0x9f4, 0x9fa, 0xa02, 0xa05, 0xa0f, 0xa13, 0xa2a, 0xa32, 0xa35, 0xa38, 0xa3c, 0xa3e, 0xa41, 0xa47, 0xa4b, 0xa59, 0xa5e, 0xa66, 0xa70, - 0xa72, 0xa81, 0xa83, 0xa85, 0xa8d, 0xa8f, 0xa93, 0xaaa, 0xab2, 0xab5, 0xabc, 0xabe, 0xac1, 0xac7, 0xac9, 0xacb, 0xacd, 0xad0, 0xae0, 0xae6, - 0xb01, 0xb03, 0xb05, 0xb0f, 0xb13, 0xb2a, 0xb32, 0xb36, 0xb3c, 0xb3e, 0xb42, 0xb47, 0xb4b, 0xb4d, 0xb56, 0xb5c, 0xb5f, 0xb66, 0xb70, 0xb82, - 0xb85, 0xb8e, 0xb92, 0xb99, 0xb9c, 0xb9e, 0xba3, 0xba8, 0xbae, 0xbb7, 0xbbe, 0xbc0, 0xbc2, 0xbc6, 0xbca, 0xbcd, 0xbd7, 0xbe7, 0xbf0, 0xc01, - 0xc05, 0xc0e, 0xc12, 0xc2a, 0xc35, 0xc3e, 0xc41, 0xc46, 0xc4a, 0xc55, 0xc60, 0xc66, 0xc82, 0xc85, 0xc8e, 0xc92, 0xcaa, 0xcb5, 0xcbe, 0xcc1, - 0xcc6, 0xcc8, 0xcca, 0xccc, 0xcd5, 0xcde, 0xce0, 0xce6, 0xd02, 0xd05, 0xd0e, 0xd12, 0xd2a, 0xd3e, 0xd41, 0xd46, 0xd4a, 0xd4d, 0xd57, 0xd60, - 0xd66, 0xd82, 0xd85, 0xd9a, 0xdb3, 0xdbd, 0xdc0, 0xdca, 0xdcf, 0xdd2, 0xdd6, 0xdd8, 0xdf2, 0xdf4, 0xe01, 0xe31, 0xe33, 0xe35, 0xe3f, 0xe41, - 0xe46, 0xe48, 0xe4f, 0xe51, 0xe5a, 0xe81, 0xe84, 0xe87, 0xe8a, 0xe8d, 0xe94, 0xe99, 0xea1, 0xea5, 0xea7, 0xeaa, 0xead, 0xeb1, 0xeb3, 0xeb5, - 0xebb, 0xebd, 0xec0, 0xec6, 0xec8, 0xed0, 0xedc, 0xf00, 0xf02, 0xf04, 0xf13, 0xf18, 0xf1a, 0xf20, 0xf2a, 0xf34, 0xf3a, 0xf3e, 0xf40, 0xf49, - 0xf71, 0xf7f, 0xf81, 0xf85, 0xf87, 0xf89, 0xf90, 0xf99, 0xfbe, 0xfc6, 0xfc8, 0xfcf, 0x1000, 0x1023, 0x1029, 0x102c, 0x102e, 0x1031, 0x1036, 0x1038, - 0x1040, 0x104a, 0x1050, 0x1056, 0x1058, 0x10a0, 0x10d0, 0x10fb, 0x1100, 0x115f, 0x11a8, 0x1200, 0x1208, 0x1248, 0x124a, 0x1250, 0x1258, 0x125a, 0x1260, 0x1288, - 0x128a, 0x1290, 0x12b0, 0x12b2, 0x12b8, 0x12c0, 0x12c2, 0x12c8, 0x12d0, 0x12d8, 0x12f0, 0x1310, 0x1312, 0x1318, 0x1320, 0x1348, 0x1361, 0x1369, 0x1372, 0x13a0, - 0x1401, 0x166d, 0x166f, 0x1680, 0x1682, 0x169b, 0x16a0, 0x16eb, 0x16ee, 0x1780, 0x17b4, 0x17b7, 0x17be, 0x17c6, 0x17c8, 0x17ca, 0x17d4, 0x17db, 0x17e0, 0x1800, - 0x1806, 0x1808, 0x180b, 0x1810, 0x1820, 0x1843, 0x1845, 0x1880, 0x18a9, 0x1e00, 0x1e96, 0x1ea0, 0x1f00, 0x1f08, 0x1f10, 0x1f18, 0x1f20, 0x1f28, 0x1f30, 0x1f38, - 0x1f40, 0x1f48, 0x1f50, 0x1f59, 0x1f5b, 0x1f5d, 0x1f5f, 0x1f61, 0x1f68, 0x1f70, 0x1f80, 0x1f88, 0x1f90, 0x1f98, 0x1fa0, 0x1fa8, 0x1fb0, 0x1fb6, 0x1fb8, 0x1fbc, - 0x1fbe, 0x1fc0, 0x1fc2, 0x1fc6, 0x1fc8, 0x1fcc, 0x1fce, 0x1fd0, 0x1fd6, 0x1fd8, 0x1fdd, 0x1fe0, 0x1fe8, 0x1fed, 0x1ff2, 0x1ff6, 0x1ff8, 0x1ffc, 0x1ffe, 0x2000, - 0x200c, 0x2010, 0x2016, 0x2018, 0x201a, 0x201c, 0x201e, 0x2020, 0x2028, 0x202a, 0x202f, 0x2031, 0x2039, 0x203b, 0x203f, 0x2041, 0x2044, 0x2046, 0x2048, 0x206a, - 0x2070, 0x2074, 0x207a, 0x207d, 0x207f, 0x2081, 0x208a, 0x208d, 0x20a0, 0x20d0, 0x20dd, 0x20e1, 0x20e3, 0x2100, 0x2102, 0x2104, 0x2107, 0x2109, 0x210b, 0x210e, - 0x2110, 0x2113, 0x2115, 0x2117, 0x2119, 0x211e, 0x2124, 0x212b, 0x212e, 0x2130, 0x2132, 0x2134, 0x2136, 0x2139, 0x2153, 0x2160, 0x2190, 0x2195, 0x219a, 0x219c, - 0x21a0, 0x21a2, 0x21a5, 0x21a8, 0x21ae, 0x21b0, 0x21ce, 0x21d0, 0x21d2, 0x21d6, 0x2200, 0x2300, 0x2308, 0x230c, 0x2320, 0x2322, 0x2329, 0x232b, 0x237d, 0x2400, - 0x2440, 0x2460, 0x249c, 0x24ea, 0x2500, 0x25a0, 0x25b7, 0x25b9, 0x25c1, 0x25c3, 0x2600, 0x2619, 0x266f, 0x2671, 0x2701, 0x2706, 0x270c, 0x2729, 0x274d, 0x274f, - 0x2756, 0x2758, 0x2761, 0x2776, 0x2794, 0x2798, 0x27b1, 0x2800, 0x2e80, 0x2e9b, 0x2f00, 0x2ff0, 0x3000, 0x3002, 0x3004, 0x3006, 0x3008, 0x3012, 0x3014, 0x301c, - 0x301e, 0x3020, 0x3022, 0x302a, 0x3030, 0x3032, 0x3036, 0x3038, 0x303e, 0x3041, 0x3099, 0x309b, 0x309d, 0x30a1, 0x30fb, 0x30fd, 0x3105, 0x3131, 0x3190, 0x3192, - 0x3196, 0x31a0, 0x3200, 0x3220, 0x322a, 0x3260, 0x327f, 0x3281, 0x328a, 0x32c0, 0x32d0, 0x3300, 0x337b, 0x33e0, 0x3400, 0x4e00, 0xa000, 0xa490, 0xa4a4, 0xa4b5, - 0xa4c2, 0xa4c6, 0xac00, 0xd800, 0xe000, 0xf900, 0xfb00, 0xfb13, 0xfb1d, 0xfb20, 0xfb29, 0xfb2b, 0xfb38, 0xfb3e, 0xfb40, 0xfb43, 0xfb46, 0xfbd3, 0xfd3e, 0xfd50, - 0xfd92, 0xfdf0, 0xfe20, 0xfe30, 0xfe32, 0xfe34, 0xfe36, 0xfe49, 0xfe4d, 0xfe50, 0xfe54, 0xfe58, 0xfe5a, 0xfe5f, 0xfe62, 0xfe65, 0xfe68, 0xfe6b, 0xfe70, 0xfe74, - 0xfe76, 0xfeff, 0xff01, 0xff04, 0xff06, 0xff08, 0xff0a, 0xff0d, 0xff0f, 0xff11, 0xff1a, 0xff1c, 0xff1f, 0xff21, 0xff3b, 0xff3d, 0xff3f, 0xff41, 0xff5b, 0xff5d, - 0xff61, 0xff63, 0xff65, 0xff67, 0xff70, 0xff72, 0xff9e, 0xffa0, 0xffc2, 0xffca, 0xffd2, 0xffda, 0xffe0, 0xffe2, 0xffe4, 0xffe6, 0xffe8, 0xffea, 0xffed, 0xfff9, - 0xfffc -}; - -constexpr KChar typeValues[] = { - 0x1f, 0xf, 0x21, 0x180c, 0x23, 0x18, 0x25, 0x181a, 0x27, 0x18, 0x29, 0x1615, 0x2c, 0x1918, 0x2e, 0x1418, 0x30, 0x1809, 0x39, 0x9, - 0x3b, 0x18, 0x3e, 0x19, 0x40, 0x18, 0x5a, 0x1, 0x5c, 0x1518, 0x5e, 0x161b, 0x60, 0x171b, 0x7a, 0x2, 0x7c, 0x1519, 0x7e, 0x1619, - 0x9f, 0xf, 0xa1, 0x180c, 0xa5, 0x1a, 0xa7, 0x1c, 0xa9, 0x1c1b, 0xab, 0x1d02, 0xad, 0x1419, 0xb0, 0x1b1c, 0xb2, 0x190b, 0xb4, 0xb1b, - 0xb6, 0x21c, 0xb8, 0x181b, 0xba, 0xb02, 0xbc, 0x1e0b, 0xbe, 0xb, 0xc0, 0x1801, 0xd6, 0x1, 0xd8, 0x1901, 0xde, 0x1, 0xf6, 0x2, - 0xf8, 0x1902, 0xff, 0x2, 0x137, 0x201, 0x148, 0x102, 0x178, 0x201, 0x17e, 0x102, 0x180, 0x2, 0x182, 0x1, 0x186, 0x201, 0x189, 0x102, - 0x18b, 0x1, 0x18d, 0x2, 0x191, 0x1, 0x193, 0x102, 0x196, 0x201, 0x198, 0x1, 0x19b, 0x2, 0x19d, 0x1, 0x19f, 0x102, 0x1a6, 0x201, - 0x1aa, 0x102, 0x1ae, 0x201, 0x1b1, 0x102, 0x1b3, 0x1, 0x1b7, 0x102, 0x1b9, 0x201, 0x1bb, 0x502, 0x1bd, 0x201, 0x1bf, 0x2, 0x1c3, 0x5, - 0x1c5, 0x301, 0x1c7, 0x102, 0x1c9, 0x203, 0x1cb, 0x301, 0x1dc, 0x102, 0x1ef, 0x201, 0x1f1, 0x102, 0x1f3, 0x203, 0x1f6, 0x201, 0x1f8, 0x1, - 0x21f, 0x201, 0x233, 0x201, 0x2ad, 0x2, 0x2b8, 0x4, 0x2ba, 0x1b, 0x2c1, 0x4, 0x2cf, 0x1b, 0x2d1, 0x4, 0x2df, 0x1b, 0x2e4, 0x4, - 0x2ed, 0x1b, 0x2ee, 0x4, 0x34e, 0x6, 0x362, 0x6, 0x375, 0x1b, 0x37a, 0x4, 0x37e, 0x18, 0x385, 0x1b, 0x388, 0x1801, 0x38a, 0x1, - 0x38c, 0x1, 0x38f, 0x1, 0x391, 0x102, 0x3a1, 0x1, 0x3ab, 0x1, 0x3ce, 0x2, 0x3d1, 0x2, 0x3d4, 0x1, 0x3d7, 0x2, 0x3ef, 0x201, - 0x3f3, 0x2, 0x42f, 0x1, 0x45f, 0x2, 0x481, 0x201, 0x483, 0x61c, 0x486, 0x6, 0x489, 0x7, 0x4c0, 0x201, 0x4c4, 0x102, 0x4c8, 0x102, - 0x4cc, 0x102, 0x4f5, 0x201, 0x4f9, 0x201, 0x556, 0x1, 0x55a, 0x418, 0x55f, 0x18, 0x587, 0x2, 0x58a, 0x1814, 0x5a1, 0x6, 0x5b9, 0x6, - 0x5bd, 0x6, 0x5c1, 0x618, 0x5c4, 0x1806, 0x5ea, 0x5, 0x5f2, 0x5, 0x5f4, 0x18, 0x60c, 0x18, 0x61b, 0x1800, 0x61f, 0x1800, 0x63a, 0x5, - 0x641, 0x504, 0x64a, 0x5, 0x655, 0x6, 0x669, 0x9, 0x66d, 0x18, 0x671, 0x506, 0x6d3, 0x5, 0x6d5, 0x518, 0x6dc, 0x6, 0x6de, 0x7, - 0x6e4, 0x6, 0x6e6, 0x4, 0x6e8, 0x6, 0x6ea, 0x1c06, 0x6ed, 0x6, 0x6f9, 0x9, 0x6fc, 0x5, 0x6fe, 0x1c, 0x70d, 0x18, 0x710, 0x1005, - 0x712, 0x605, 0x72c, 0x5, 0x74a, 0x6, 0x7a5, 0x5, 0x7b0, 0x6, 0x902, 0x6, 0x903, 0x800, 0x939, 0x5, 0x93d, 0x506, 0x940, 0x8, - 0x948, 0x6, 0x94c, 0x8, 0x94d, 0x600, 0x951, 0x605, 0x954, 0x6, 0x961, 0x5, 0x963, 0x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0xea7, 0x500, 0xeab, 0x5, 0xeb0, 0x5, 0xeb2, 0x605, 0xeb4, 0x506, 0xeb9, 0x6, - 0xebc, 0x6, 0xebd, 0x500, 0xec4, 0x5, 0xec6, 0x4, 0xecd, 0x6, 0xed9, 0x9, 0xedd, 0x5, 0xf01, 0x1c05, 0xf03, 0x1c, 0xf12, 0x18, - 0xf17, 0x1c, 0xf19, 0x6, 0xf1f, 0x1c, 0xf29, 0x9, 0xf33, 0xb, 0xf39, 0x61c, 0xf3d, 0x1615, 0xf3f, 0x8, 0xf47, 0x5, 0xf6a, 0x5, - 0xf7e, 0x6, 0xf80, 0x806, 0xf84, 0x6, 0xf86, 0x1806, 0xf88, 0x605, 0xf8b, 0x5, 0xf97, 0x6, 0xfbc, 0x6, 0xfc5, 0x1c, 0xfc7, 0x1c06, - 0xfcc, 0x1c, 0xfcf, 0x1c00, 0x1021, 0x5, 0x1027, 0x5, 0x102a, 0x5, 0x102d, 0x608, 0x1030, 0x6, 0x1032, 0x806, 0x1037, 0x6, 0x1039, 0x608, - 0x1049, 0x9, 0x104f, 0x18, 0x1055, 0x5, 0x1057, 0x8, 0x1059, 0x6, 0x10c5, 0x1, 0x10f6, 0x5, 0x10fb, 0x1800, 0x1159, 0x5, 0x11a2, 0x5, - 0x11f9, 0x5, 0x1206, 0x5, 0x1246, 0x5, 0x1248, 0x5, 0x124d, 0x5, 0x1256, 0x5, 0x1258, 0x5, 0x125d, 0x5, 0x1286, 0x5, 0x1288, 0x5, - 0x128d, 0x5, 0x12ae, 0x5, 0x12b0, 0x5, 0x12b5, 0x5, 0x12be, 0x5, 0x12c0, 0x5, 0x12c5, 0x5, 0x12ce, 0x5, 0x12d6, 0x5, 0x12ee, 0x5, - 0x130e, 0x5, 0x1310, 0x5, 0x1315, 0x5, 0x131e, 0x5, 0x1346, 0x5, 0x135a, 0x5, 0x1368, 0x18, 0x1371, 0x9, 0x137c, 0xb, 0x13f4, 0x5, - 0x166c, 0x5, 0x166e, 0x18, 0x1676, 0x5, 0x1681, 0x50c, 0x169a, 0x5, 0x169c, 0x1516, 0x16ea, 0x5, 0x16ed, 0x18, 0x16f0, 0xb, 0x17b3, 0x5, - 0x17b6, 0x8, 0x17bd, 0x6, 0x17c5, 0x8, 0x17c7, 0x806, 0x17c9, 0x608, 0x17d3, 0x6, 0x17da, 0x18, 0x17dc, 0x1a18, 0x17e9, 0x9, 0x1805, 0x18, - 0x1807, 0x1814, 0x180a, 0x18, 0x180e, 0x10, 0x1819, 0x9, 0x1842, 0x5, 0x1844, 0x405, 0x1877, 0x5, 0x18a8, 0x5, 0x18a9, 0x600, 0x1e95, 0x201, - 0x1e9b, 0x2, 0x1ef9, 0x201, 0x1f07, 0x2, 0x1f0f, 0x1, 0x1f15, 0x2, 0x1f1d, 0x1, 0x1f27, 0x2, 0x1f2f, 0x1, 0x1f37, 0x2, 0x1f3f, 0x1, - 0x1f45, 0x2, 0x1f4d, 0x1, 0x1f57, 0x2, 0x1f59, 0x100, 0x1f5b, 0x100, 0x1f5d, 0x100, 0x1f60, 0x102, 0x1f67, 0x2, 0x1f6f, 0x1, 0x1f7d, 0x2, - 0x1f87, 0x2, 0x1f8f, 0x3, 0x1f97, 0x2, 0x1f9f, 0x3, 0x1fa7, 0x2, 0x1faf, 0x3, 0x1fb4, 0x2, 0x1fb7, 0x2, 0x1fbb, 0x1, 0x1fbd, 0x1b03, - 0x1fbf, 0x1b02, 0x1fc1, 0x1b, 0x1fc4, 0x2, 0x1fc7, 0x2, 0x1fcb, 0x1, 0x1fcd, 0x1b03, 0x1fcf, 0x1b, 0x1fd3, 0x2, 0x1fd7, 0x2, 0x1fdb, 0x1, - 0x1fdf, 0x1b, 0x1fe7, 0x2, 0x1fec, 0x1, 0x1fef, 0x1b, 0x1ff4, 0x2, 0x1ff7, 0x2, 0x1ffb, 0x1, 0x1ffd, 0x1b03, 0x1ffe, 0x1b, 0x200b, 0xc, - 0x200f, 0x10, 0x2015, 0x14, 0x2017, 0x18, 0x2019, 0x1e1d, 0x201b, 0x1d15, 0x201d, 0x1e1d, 0x201f, 0x1d15, 0x2027, 0x18, 0x2029, 0xe0d, 0x202e, 0x10, - 0x2030, 0xc18, 0x2038, 0x18, 0x203a, 0x1d1e, 0x203e, 0x18, 0x2040, 0x17, 0x2043, 0x18, 0x2045, 0x1519, 0x2046, 0x16, 0x204d, 0x18, 0x206f, 0x10, - 0x2070, 0xb, 0x2079, 0xb, 0x207c, 0x19, 0x207e, 0x1516, 0x2080, 0x20b, 0x2089, 0xb, 0x208c, 0x19, 0x208e, 0x1516, 0x20af, 0x1a, 0x20dc, 0x6, - 0x20e0, 0x7, 0x20e2, 0x607, 0x20e3, 0x700, 0x2101, 0x1c, 0x2103, 0x1c01, 0x2106, 0x1c, 0x2108, 0x11c, 0x210a, 0x1c02, 0x210d, 0x1, 0x210f, 0x2, - 0x2112, 0x1, 0x2114, 0x21c, 0x2116, 0x11c, 0x2118, 0x1c, 0x211d, 0x1, 0x2123, 0x1c, 0x212a, 0x1c01, 0x212d, 0x1, 0x212f, 0x21c, 0x2131, 0x1, - 0x2133, 0x11c, 0x2135, 0x502, 0x2138, 0x5, 0x213a, 0x21c, 0x215f, 0xb, 0x2183, 0xa, 0x2194, 0x19, 0x2199, 0x1c, 0x219b, 0x19, 0x219f, 0x1c, - 0x21a1, 0x1c19, 0x21a4, 0x191c, 0x21a7, 0x1c19, 0x21ad, 0x1c, 0x21af, 0x1c19, 0x21cd, 0x1c, 0x21cf, 0x19, 0x21d1, 0x1c, 0x21d5, 0x1c19, 0x21f3, 0x1c, - 0x22f1, 0x19, 0x2307, 0x1c, 0x230b, 0x19, 0x231f, 0x1c, 0x2321, 0x19, 0x2328, 0x1c, 0x232a, 0x1516, 0x237b, 0x1c, 0x239a, 0x1c, 0x2426, 0x1c, - 0x244a, 0x1c, 0x249b, 0xb, 0x24e9, 0x1c, 0x24ea, 0xb, 0x2595, 0x1c, 0x25b6, 0x1c, 0x25b8, 0x191c, 0x25c0, 0x1c, 0x25c2, 0x191c, 0x25f7, 0x1c, - 0x2613, 0x1c, 0x266e, 0x1c, 0x2670, 0x191c, 0x2671, 0x1c00, 0x2704, 0x1c, 0x2709, 0x1c, 0x2727, 0x1c, 0x274b, 0x1c, 0x274d, 0x1c00, 0x2752, 0x1c, - 0x2756, 0x1c, 0x275e, 0x1c, 0x2767, 0x1c, 0x2793, 0xb, 0x2794, 0x1c, 0x27af, 0x1c, 0x27be, 0x1c, 0x28ff, 0x1c, 0x2e99, 0x1c, 0x2ef3, 0x1c, - 0x2fd5, 0x1c, 0x2ffb, 0x1c, 0x3001, 0x180c, 0x3003, 0x18, 0x3005, 0x41c, 0x3007, 0xa05, 0x3011, 0x1615, 0x3013, 0x1c, 0x301b, 0x1615, 0x301d, 0x1514, - 0x301f, 0x16, 0x3021, 0xa1c, 0x3029, 0xa, 0x302f, 0x6, 0x3031, 0x414, 0x3035, 0x4, 0x3037, 0x1c, 0x303a, 0xa, 0x303f, 0x1c, 0x3094, 0x5, - 0x309a, 0x6, 0x309c, 0x1b, 0x309e, 0x4, 0x30fa, 0x5, 0x30fc, 0x1704, 0x30fe, 0x4, 0x312c, 0x5, 0x318e, 0x5, 0x3191, 0x1c, 0x3195, 0xb, - 0x319f, 0x1c, 0x31b7, 0x5, 0x321c, 0x1c, 0x3229, 0xb, 0x3243, 0x1c, 0x327b, 0x1c, 0x3280, 0x1c0b, 0x3289, 0xb, 0x32b0, 0x1c, 0x32cb, 0x1c, - 0x32fe, 0x1c, 0x3376, 0x1c, 0x33dd, 0x1c, 0x33fe, 0x1c, 0x4db5, 0x5, 0x9fa5, 0x5, 0xa48c, 0x5, 0xa4a1, 0x1c, 0xa4b3, 0x1c, 0xa4c0, 0x1c, - 0xa4c4, 0x1c, 0xa4c6, 0x1c, 0xd7a3, 0x5, 0xdfff, 0x13, 0xf8ff, 0x12, 0xfa2d, 0x5, 0xfb06, 0x2, 0xfb17, 0x2, 0xfb1f, 0x506, 0xfb28, 0x5, - 0xfb2a, 0x1905, 0xfb36, 0x5, 0xfb3c, 0x5, 0xfb3e, 0x5, 0xfb41, 0x5, 0xfb44, 0x5, 0xfbb1, 0x5, 0xfd3d, 0x5, 0xfd3f, 0x1615, 0xfd8f, 0x5, - 0xfdc7, 0x5, 0xfdfb, 0x5, 0xfe23, 0x6, 0xfe31, 0x1418, 0xfe33, 0x1714, 0xfe35, 0x1517, 0xfe44, 0x1516, 0xfe4c, 0x18, 0xfe4f, 0x17, 0xfe52, 0x18, - 0xfe57, 0x18, 0xfe59, 0x1514, 0xfe5e, 0x1516, 0xfe61, 0x18, 0xfe64, 0x1419, 0xfe66, 0x19, 0xfe6a, 0x1a18, 0xfe6b, 0x1800, 0xfe72, 0x5, 0xfe74, 0x5, - 0xfefc, 0x5, 0xfeff, 0x1000, 0xff03, 0x18, 0xff05, 0x181a, 0xff07, 0x18, 0xff09, 0x1615, 0xff0c, 0x1918, 0xff0e, 0x1418, 0xff10, 0x1809, 0xff19, 0x9, - 0xff1b, 0x18, 0xff1e, 0x19, 0xff20, 0x18, 0xff3a, 0x1, 0xff3c, 0x1518, 0xff3e, 0x161b, 0xff40, 0x171b, 0xff5a, 0x2, 0xff5c, 0x1519, 0xff5e, 0x1619, - 0xff62, 0x1815, 0xff64, 0x1618, 0xff66, 0x1705, 0xff6f, 0x5, 0xff71, 0x504, 0xff9d, 0x5, 0xff9f, 0x4, 0xffbe, 0x5, 0xffc7, 0x5, 0xffcf, 0x5, - 0xffd7, 0x5, 0xffdc, 0x5, 0xffe1, 0x1a, 0xffe3, 0x1b19, 0xffe5, 0x1a1c, 0xffe6, 0x1a, 0xffe9, 0x191c, 0xffec, 0x19, 0xffee, 0x1c, 0xfffb, 0x10 -}; - -KInt getType(KChar ch) { - if (ch < 1000) { - return typeValuesCache[ch]; - } - int result = binarySearchRange(typeKeys, ARRAY_SIZE(typeKeys), ch); - int high = typeValues[result * 2]; - if (ch <= high) { - int code = typeValues[result * 2 + 1]; - if (code < 0x100) { - return code; - } - return (ch & 1) == 1 ? code >> 8 : code & 0xff; - } - return UNASSIGNED; -} - KChar towupper_Konan(KChar ch) { // Optimized case for ASCII. if ('a' <= ch && ch <= 'z') { @@ -636,72 +307,6 @@ KChar towlower_Konan(KChar ch) { return ch; } -int iswdigit_Konan(KChar ch) { - // Optimized case for ASCII. - if ('0' <= ch && ch <= '9') { - return true; - } - if (ch < 1632) { - return false; - } - return getType(ch) == DECIMAL_DIGIT_NUMBER; -} - -int iswalpha_Konan(KChar ch) { - if (('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z')) { - return true; - } - if (ch < 128) { - return false; - } - int type = getType(ch); - return type >= UPPERCASE_LETTER && type <= OTHER_LETTER; -} - -int iswalnum_Konan(KChar ch) { - int type = getType(ch); - return (type >= UPPERCASE_LETTER && type <= OTHER_LETTER) - || type == DECIMAL_DIGIT_NUMBER; -} - -int iswspace_Konan(KChar ch) { - // FILE, GROUP, RECORD, UNIT separators, # Zs SPACE or # Cc CONTROLs - if ((ch >= 0x1c && ch <= 0x20) || (ch >= 0x9 && ch <= 0xd)) { - return true; - } - // not (# Zs OGHAM SPACE MARK or # Cc or # Zs NO-BREAK SPACE) - if (ch < 0x2000 && !(ch == 0x1680 || ch == 0x85 || ch == 0xA0)) { - return false; - } - // if # Zl LINE SEPARATOR or # Zp PARAGRAPH SEPARATOR or # Zs NARROW NO-BREAK SPACE - // or # Zs MEDIUM MATHEMATICAL SPACE or # Zs IDEOGRAPHIC SPACE - return ch < 0x200b || ch == 0x2028 || ch == 0x2029 || ch == 0x202F || ch == 0x205F || ch == 0x3000; -} - -int iswupper_Konan(KChar ch) { - // Optimized case for ASCII. - if ('A' <= ch && ch <= 'Z') { - return true; - } - if (ch < 128) { - return false; - } - - return getType(ch) == UPPERCASE_LETTER; -} - -int iswlower_Konan(KChar ch) { - // Optimized case for ASCII. - if ('a' <= ch && ch <= 'z') { - return true; - } - if (ch < 128) { - return false; - } - - return getType(ch) == LOWERCASE_LETTER; -} - } // namespace extern "C" { @@ -989,24 +594,6 @@ KBoolean Kotlin_String_regionMatches(KString thiz, KInt thizOffset, return true; } -KBoolean Kotlin_Char_isDefined(KChar ch) { - // TODO: fixme! - RuntimeAssert(false, "Kotlin_Char_isDefined() is not implemented"); - return true; -} - -KBoolean Kotlin_Char_isLetter(KChar ch) { - return iswalpha_Konan(ch) != 0; -} - -KBoolean Kotlin_Char_isLetterOrDigit(KChar ch) { - return iswalnum_Konan(ch) != 0; -} - -KBoolean Kotlin_Char_isDigit(KChar ch) { - return iswdigit_Konan(ch) != 0; -} - KBoolean Kotlin_Char_isIdentifierIgnorable(KChar ch) { RuntimeAssert(false, "Kotlin_Char_isIdentifierIgnorable() is not implemented"); return false; @@ -1024,18 +611,6 @@ KBoolean Kotlin_Char_isLowSurrogate(KChar ch) { return ((ch & 0xfc00) == 0xdc00); } -KBoolean Kotlin_Char_isWhitespace(KChar ch) { - return iswspace_Konan(ch) != 0; -} - -KBoolean Kotlin_Char_isLowerCase(KChar ch) { - return iswlower_Konan(ch) != 0; -} - -KBoolean Kotlin_Char_isUpperCase(KChar ch) { - return iswupper_Konan(ch) != 0; -} - KChar Kotlin_Char_toLowerCase(KChar ch) { return towlower_Konan(ch); } @@ -1044,10 +619,6 @@ KChar Kotlin_Char_toUpperCase(KChar ch) { return towupper_Konan(ch); } -KInt Kotlin_Char_getType(KChar ch) { - return getType(ch); -} - constexpr KInt digits[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, diff --git a/kotlin-native/runtime/src/main/kotlin/generated/_CharCategories.kt b/kotlin-native/runtime/src/main/kotlin/generated/_CharCategories.kt new file mode 100644 index 00000000000..541a012d5fd --- /dev/null +++ b/kotlin-native/runtime/src/main/kotlin/generated/_CharCategories.kt @@ -0,0 +1,184 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.text + +// +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt +// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib +// + +// 1343 ranges totally +@SharedImmutable +private val rangeStart = intArrayOf( + 0x0000, 0x0020, 0x0022, 0x0027, 0x002b, 0x002e, 0x0030, 0x003a, 0x003c, 0x003f, 0x0041, 0x005b, 0x005e, 0x0061, 0x007b, 0x007e, 0x007f, 0x00a0, 0x00a2, 0x00a6, + 0x00aa, 0x00ad, 0x00b0, 0x00b3, 0x00b6, 0x00b9, 0x00bd, 0x00c0, 0x00d7, 0x00d8, 0x00df, 0x00f7, 0x00f8, 0x00ff, 0x0138, 0x0149, 0x0179, 0x017f, 0x0182, 0x0184, + 0x018b, 0x018e, 0x0190, 0x0198, 0x019b, 0x01a0, 0x01a7, 0x01aa, 0x01ac, 0x01b3, 0x01b8, 0x01bb, 0x01bd, 0x01c0, 0x01c4, 0x01cc, 0x01dd, 0x01f0, 0x01f4, 0x01f8, + 0x0233, 0x0239, 0x0240, 0x0243, 0x0246, 0x024f, 0x0294, 0x0295, 0x02b0, 0x02c2, 0x02c6, 0x02d2, 0x02e0, 0x02e5, 0x02eb, 0x02ef, 0x0300, 0x0370, 0x0374, 0x0377, + 0x037a, 0x037d, 0x0380, 0x0384, 0x0386, 0x038a, 0x038f, 0x0391, 0x03a2, 0x03a3, 0x03ac, 0x03cd, 0x03d2, 0x03d5, 0x03d7, 0x03ef, 0x03f4, 0x03f9, 0x03fb, 0x03fd, + 0x0430, 0x045f, 0x0482, 0x0483, 0x0488, 0x048a, 0x04c1, 0x04cf, 0x0530, 0x0531, 0x0557, 0x055a, 0x0560, 0x0589, 0x058c, 0x058f, 0x0591, 0x05be, 0x05bf, 0x05c8, + 0x05d0, 0x05eb, 0x05ef, 0x05f3, 0x05f5, 0x0600, 0x0606, 0x0609, 0x060e, 0x0610, 0x061b, 0x061e, 0x0620, 0x0640, 0x0641, 0x064b, 0x0660, 0x066a, 0x066e, 0x0671, + 0x06d3, 0x06d6, 0x06dd, 0x06df, 0x06e4, 0x06e8, 0x06ea, 0x06ee, 0x06f0, 0x06fa, 0x06fc, 0x0700, 0x070e, 0x0711, 0x0712, 0x0730, 0x074b, 0x074d, 0x07a6, 0x07b1, + 0x07b2, 0x07c0, 0x07ca, 0x07eb, 0x07f4, 0x07f7, 0x07fa, 0x07fd, 0x0800, 0x0816, 0x081a, 0x081b, 0x0822, 0x0827, 0x0829, 0x082e, 0x0830, 0x083f, 0x0840, 0x0859, + 0x085c, 0x0860, 0x086b, 0x08a0, 0x08b5, 0x08b6, 0x08c8, 0x08d3, 0x08e2, 0x08e3, 0x0903, 0x0904, 0x093a, 0x093d, 0x093e, 0x0941, 0x0949, 0x094b, 0x0950, 0x0951, + 0x0958, 0x0962, 0x0964, 0x0966, 0x0970, 0x0972, 0x0981, 0x0984, 0x0985, 0x098c, 0x0990, 0x0993, 0x09a9, 0x09aa, 0x09b1, 0x09b5, 0x09b8, 0x09bb, 0x09be, 0x09c1, + 0x09c5, 0x09c8, 0x09cc, 0x09cf, 0x09d7, 0x09d8, 0x09db, 0x09e1, 0x09e4, 0x09e6, 0x09f0, 0x09f2, 0x09f4, 0x09fa, 0x09fd, 0x0a00, 0x0a03, 0x0a05, 0x0a0b, 0x0a0f, + 0x0a11, 0x0a13, 0x0a29, 0x0a2a, 0x0a2f, 0x0a3b, 0x0a3e, 0x0a41, 0x0a43, 0x0a46, 0x0a4a, 0x0a4d, 0x0a50, 0x0a52, 0x0a59, 0x0a5c, 0x0a5f, 0x0a66, 0x0a70, 0x0a73, + 0x0a76, 0x0a77, 0x0a81, 0x0a84, 0x0a85, 0x0a8c, 0x0a91, 0x0a93, 0x0aa9, 0x0aaa, 0x0aaf, 0x0ab5, 0x0aba, 0x0abd, 0x0abe, 0x0ac1, 0x0ac4, 0x0ac9, 0x0acd, 0x0ad0, + 0x0ad1, 0x0ae0, 0x0ae3, 0x0ae6, 0x0af0, 0x0af2, 0x0af9, 0x0afa, 0x0b00, 0x0b03, 0x0b05, 0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0x0dc8, 0x0dcd, 0x0dd0, 0x0dd3, 0x0dd7, 0x0dd8, 0x0de0, 0x0de6, 0x0df0, 0x0df3, 0x0df5, 0x0e01, 0x0e2f, + 0x0e34, 0x0e3b, 0x0e3f, 0x0e40, 0x0e46, 0x0e47, 0x0e4f, 0x0e50, 0x0e5a, 0x0e5c, 0x0e80, 0x0e85, 0x0e86, 0x0e8b, 0x0e8c, 0x0ea3, 0x0ea7, 0x0eaf, 0x0eb4, 0x0ebd, + 0x0ec0, 0x0ec5, 0x0ec8, 0x0ece, 0x0ed0, 0x0eda, 0x0edc, 0x0ee0, 0x0f00, 0x0f01, 0x0f04, 0x0f13, 0x0f17, 0x0f1a, 0x0f20, 0x0f2a, 0x0f34, 0x0f3a, 0x0f3e, 0x0f40, + 0x0f48, 0x0f49, 0x0f6d, 0x0f71, 0x0f7f, 0x0f80, 0x0f83, 0x0f88, 0x0f8d, 0x0f98, 0x0f99, 0x0fbd, 0x0fbe, 0x0fc6, 0x0fc7, 0x0fcb, 0x0fd0, 0x0fd5, 0x0fd9, 0x0fdb, + 0x1000, 0x102b, 0x102d, 0x1031, 0x1032, 0x1036, 0x103c, 0x103f, 0x1040, 0x104a, 0x1050, 0x1056, 0x1059, 0x105c, 0x105f, 0x1062, 0x1065, 0x1067, 0x106e, 0x1071, + 0x1075, 0x1082, 0x1085, 0x1087, 0x108c, 0x1090, 0x109a, 0x109d, 0x10a0, 0x10c5, 0x10c8, 0x10cb, 0x10d0, 0x10fb, 0x10fd, 0x1100, 0x1249, 0x124a, 0x124e, 0x1250, + 0x1256, 0x125a, 0x125e, 0x1260, 0x1289, 0x128a, 0x128e, 0x1290, 0x12b1, 0x12b2, 0x12b6, 0x12b8, 0x12be, 0x12c2, 0x12c6, 0x12c8, 0x12d7, 0x12d8, 0x1311, 0x1312, + 0x1316, 0x1318, 0x135b, 0x135d, 0x1360, 0x1369, 0x137d, 0x1380, 0x1390, 0x139a, 0x13a0, 0x13f6, 0x13f8, 0x13fe, 0x1401, 0x166d, 0x166f, 0x1680, 0x1681, 0x169b, + 0x169d, 0x16a0, 0x16eb, 0x16ee, 0x16f1, 0x16f9, 0x1700, 0x170d, 0x170e, 0x1712, 0x1715, 0x1720, 0x1732, 0x1735, 0x1737, 0x1740, 0x1752, 0x1754, 0x1760, 0x176b, + 0x1770, 0x1772, 0x1774, 0x1780, 0x17b4, 0x17b7, 0x17be, 0x17c4, 0x17c9, 0x17d4, 0x17d5, 0x17da, 0x17dd, 0x17e0, 0x17ea, 0x17f0, 0x17fa, 0x1800, 0x1804, 0x1809, + 0x180c, 0x180f, 0x1810, 0x181a, 0x1820, 0x1843, 0x1844, 0x1879, 0x1880, 0x1885, 0x1887, 0x18a8, 0x18ab, 0x18b0, 0x18f6, 0x1900, 0x191f, 0x1922, 0x1925, 0x1928, + 0x192b, 0x192e, 0x1931, 0x1933, 0x1939, 0x193c, 0x193e, 0x1943, 0x1946, 0x1950, 0x196e, 0x1970, 0x1975, 0x1980, 0x19ac, 0x19b0, 0x19ca, 0x19d0, 0x19da, 0x19db, + 0x19de, 0x1a00, 0x1a17, 0x1a1a, 0x1a1d, 0x1a20, 0x1a55, 0x1a58, 0x1a5e, 0x1a61, 0x1a65, 0x1a6d, 0x1a73, 0x1a7c, 0x1a80, 0x1a8a, 0x1a90, 0x1a9a, 0x1aa0, 0x1aa7, + 0x1aa8, 0x1aae, 0x1ab0, 0x1abc, 0x1ac1, 0x1b00, 0x1b04, 0x1b05, 0x1b34, 0x1b36, 0x1b3a, 0x1b3d, 0x1b40, 0x1b45, 0x1b4c, 0x1b50, 0x1b5a, 0x1b61, 0x1b6b, 0x1b74, + 0x1b7d, 0x1b80, 0x1b83, 0x1ba1, 0x1ba4, 0x1ba7, 0x1bad, 0x1bb0, 0x1bba, 0x1be6, 0x1beb, 0x1bef, 0x1bf2, 0x1bf4, 0x1bfc, 0x1c00, 0x1c24, 0x1c2c, 0x1c34, 0x1c36, + 0x1c38, 0x1c3b, 0x1c40, 0x1c4a, 0x1c4d, 0x1c50, 0x1c5a, 0x1c78, 0x1c7e, 0x1c80, 0x1c89, 0x1c90, 0x1cbb, 0x1cbd, 0x1cc0, 0x1cc8, 0x1cd0, 0x1cd3, 0x1cd4, 0x1ce1, + 0x1ce2, 0x1ce9, 0x1ced, 0x1cee, 0x1cf2, 0x1cf7, 0x1cfa, 0x1cfb, 0x1d00, 0x1d2c, 0x1d6b, 0x1d78, 0x1d79, 0x1d9b, 0x1dc0, 0x1dfa, 0x1dfb, 0x1e00, 0x1e95, 0x1e9d, + 0x1eff, 0x1f08, 0x1f10, 0x1f16, 0x1f18, 0x1f1e, 0x1f20, 0x1f28, 0x1f30, 0x1f38, 0x1f40, 0x1f46, 0x1f48, 0x1f4e, 0x1f50, 0x1f58, 0x1f60, 0x1f68, 0x1f70, 0x1f7e, + 0x1f80, 0x1f88, 0x1f90, 0x1f98, 0x1fa0, 0x1fa8, 0x1fb0, 0x1fb3, 0x1fb8, 0x1fbc, 0x1fbf, 0x1fc2, 0x1fc3, 0x1fc8, 0x1fcc, 0x1fcf, 0x1fd2, 0x1fd5, 0x1fd8, 0x1fdc, + 0x1fdd, 0x1fe0, 0x1fe8, 0x1fed, 0x1ff0, 0x1ff3, 0x1ff8, 0x1ffc, 0x1fff, 0x2000, 0x200b, 0x2010, 0x2016, 0x2018, 0x201c, 0x2020, 0x2028, 0x202a, 0x202f, 0x2030, + 0x2039, 0x203b, 0x203e, 0x2042, 0x2045, 0x2047, 0x2052, 0x2055, 0x205f, 0x2060, 0x2065, 0x2066, 0x2070, 0x2072, 0x2074, 0x207a, 0x207d, 0x2080, 0x208a, 0x208d, + 0x2090, 0x209d, 0x20a0, 0x20c0, 0x20d0, 0x20dd, 0x20e1, 0x20e2, 0x20e5, 0x20f1, 0x2100, 0x2105, 0x210a, 0x210d, 0x2111, 0x2114, 0x2118, 0x2119, 0x211e, 0x2123, + 0x212a, 0x212e, 0x2130, 0x2134, 0x2135, 0x2139, 0x213d, 0x2140, 0x2145, 0x2146, 0x214a, 0x214d, 0x2150, 0x2160, 0x2183, 0x2185, 0x2189, 0x218c, 0x2190, 0x2195, + 0x219a, 0x219c, 0x219e, 0x21a7, 0x21ae, 0x21af, 0x21cd, 0x21d1, 0x21d5, 0x21f4, 0x2300, 0x2308, 0x230c, 0x2320, 0x2322, 0x2329, 0x232b, 0x237c, 0x237d, 0x239b, + 0x23b4, 0x23dc, 0x23e2, 0x2427, 0x2440, 0x244b, 0x2460, 0x249c, 0x24ea, 0x2500, 0x25b7, 0x25b8, 0x25c1, 0x25c2, 0x25f8, 0x2600, 0x266f, 0x2670, 0x2768, 0x2776, + 0x2794, 0x27c0, 0x27c5, 0x27c7, 0x27e6, 0x27f0, 0x2800, 0x2900, 0x2983, 0x2999, 0x29d8, 0x29dc, 0x29fc, 0x29fe, 0x2b00, 0x2b30, 0x2b45, 0x2b47, 0x2b4d, 0x2b74, + 0x2b76, 0x2b96, 0x2b97, 0x2c00, 0x2c2f, 0x2c30, 0x2c5e, 0x2c62, 0x2c65, 0x2c66, 0x2c6d, 0x2c71, 0x2c76, 0x2c7c, 0x2c7e, 0x2c80, 0x2ce3, 0x2ce5, 0x2ceb, 0x2cef, + 0x2cf2, 0x2cf4, 0x2cf9, 0x2cfb, 0x2d00, 0x2d25, 0x2d28, 0x2d2b, 0x2d30, 0x2d68, 0x2d6f, 0x2d71, 0x2d7f, 0x2d80, 0x2d97, 0x2da0, 0x2da7, 0x2da8, 0x2daf, 0x2db0, + 0x2db7, 0x2db8, 0x2dbf, 0x2dc0, 0x2dc7, 0x2dc8, 0x2dcf, 0x2dd0, 0x2dd7, 0x2dd8, 0x2ddf, 0x2de0, 0x2e00, 0x2e02, 0x2e06, 0x2e08, 0x2e0e, 0x2e15, 0x2e1b, 0x2e1f, + 0x2e22, 0x2e2a, 0x2e2f, 0x2e30, 0x2e3a, 0x2e3c, 0x2e40, 0x2e43, 0x2e4f, 0x2e53, 0x2e80, 0x2e9a, 0x2e9b, 0x2ef4, 0x2f00, 0x2fd6, 0x2ff0, 0x2ffc, 0x3000, 0x3003, + 0x3006, 0x3008, 0x3012, 0x3014, 0x301a, 0x301f, 0x3021, 0x302a, 0x302e, 0x3031, 0x3036, 0x3039, 0x303c, 0x303f, 0x3041, 0x3097, 0x309a, 0x309d, 0x30a0, 0x30a1, + 0x30fb, 0x30fe, 0x3100, 0x3105, 0x3130, 0x3131, 0x318f, 0x3192, 0x3196, 0x31a0, 0x31c0, 0x31e4, 0x31f0, 0x3200, 0x321f, 0x3220, 0x322a, 0x3248, 0x3250, 0x3251, + 0x3260, 0x3280, 0x328a, 0x32b1, 0x32c0, 0x3400, 0x4dc0, 0x4e00, 0x9ffd, 0xa000, 0xa015, 0xa016, 0xa48d, 0xa490, 0xa4c7, 0xa4d0, 0xa4f8, 0xa4fe, 0xa500, 0xa60c, + 0xa60d, 0xa610, 0xa620, 0xa62a, 0xa62c, 0xa640, 0xa66e, 0xa671, 0xa674, 0xa67e, 0xa680, 0xa69c, 0xa69e, 0xa6a0, 0xa6e6, 0xa6f0, 0xa6f2, 0xa6f8, 0xa700, 0xa717, + 0xa720, 0xa722, 0xa72f, 0xa731, 0xa770, 0xa771, 0xa778, 0xa77e, 0xa788, 0xa78b, 0xa78f, 0xa791, 0xa795, 0xa7aa, 0xa7af, 0xa7b0, 0xa7b4, 0xa7c0, 0xa7c2, 0xa7c6, + 0xa7ca, 0xa7cb, 0xa7f5, 0xa7f8, 0xa7fb, 0xa801, 0xa804, 0xa809, 0xa80c, 0xa823, 0xa826, 0xa828, 0xa82c, 0xa82d, 0xa830, 0xa836, 0xa83a, 0xa840, 0xa874, 0xa878, + 0xa880, 0xa882, 0xa8b4, 0xa8c4, 0xa8c6, 0xa8ce, 0xa8d0, 0xa8da, 0xa8e0, 0xa8f2, 0xa8f8, 0xa8fb, 0xa8ff, 0xa900, 0xa90a, 0xa926, 0xa92e, 0xa930, 0xa947, 0xa952, + 0xa954, 0xa95f, 0xa960, 0xa97d, 0xa980, 0xa983, 0xa984, 0xa9b3, 0xa9b6, 0xa9ba, 0xa9bc, 0xa9be, 0xa9c1, 0xa9ce, 0xa9d0, 0xa9da, 0xa9de, 0xa9e0, 0xa9e5, 0xa9e7, + 0xa9f0, 0xa9fa, 0xa9ff, 0xaa00, 0xaa29, 0xaa2e, 0xaa32, 0xaa35, 0xaa37, 0xaa40, 0xaa43, 0xaa44, 0xaa4c, 0xaa4e, 0xaa50, 0xaa5a, 0xaa5c, 0xaa60, 0xaa70, 0xaa71, + 0xaa77, 0xaa7a, 0xaa7d, 0xaa7e, 0xaab0, 0xaab4, 0xaab7, 0xaab9, 0xaabd, 0xaac2, 0xaac3, 0xaadb, 0xaade, 0xaae0, 0xaaeb, 0xaaef, 0xaaf2, 0xaaf5, 0xaaf7, 0xab01, + 0xab07, 0xab09, 0xab0f, 0xab11, 0xab17, 0xab20, 0xab27, 0xab28, 0xab2f, 0xab30, 0xab5b, 0xab5c, 0xab60, 0xab69, 0xab6c, 0xab70, 0xabc0, 0xabe3, 0xabeb, 0xabee, + 0xabf0, 0xabfa, 0xac00, 0xd7a4, 0xd7b0, 0xd7c7, 0xd7cb, 0xd7fc, 0xd800, 0xe000, 0xf900, 0xfa6e, 0xfa70, 0xfada, 0xfb00, 0xfb07, 0xfb13, 0xfb18, 0xfb1d, 0xfb1f, + 0xfb29, 0xfb2a, 0xfb37, 0xfb38, 0xfb3d, 0xfb3e, 0xfb46, 0xfbb2, 0xfbc2, 0xfbd3, 0xfd3e, 0xfd40, 0xfd50, 0xfd90, 0xfd92, 0xfdc8, 0xfdf0, 0xfdfc, 0xfdfe, 0xfe00, + 0xfe10, 0xfe16, 0xfe1a, 0xfe20, 0xfe30, 0xfe33, 0xfe35, 0xfe45, 0xfe48, 0xfe4b, 0xfe4e, 0xfe51, 0xfe56, 0xfe59, 0xfe5f, 0xfe62, 0xfe66, 0xfe68, 0xfe6c, 0xfe70, + 0xfe75, 0xfe76, 0xfefd, 0xff01, 0xff02, 0xff07, 0xff0b, 0xff0e, 0xff10, 0xff1a, 0xff1c, 0xff1f, 0xff21, 0xff3b, 0xff3e, 0xff41, 0xff5b, 0xff5e, 0xff5f, 0xff64, + 0xff66, 0xff70, 0xff71, 0xff9e, 0xffa0, 0xffbf, 0xffc2, 0xffc8, 0xffca, 0xffd0, 0xffd2, 0xffd7, 0xffdb, 0xffde, 0xffe1, 0xffe4, 0xffe7, 0xffe9, 0xffed, 0xffef, + 0xfff9, 0xfffc, 0xfffe, +) + +@SharedImmutable +private val rangeCategory = intArrayOf( + 0x000f, 0x030c, 0x6b18, 0x5ab8, 0x5319, 0x0018, 0x0009, 0x0018, 0x0019, 0x0018, 0x0001, 0x5b15, 0x02fb, 0x0002, 0x5b35, 0x0019, 0x000f, 0x030c, 0x001a, 0x6f1c, + 0x67a5, 0x6f90, 0x2f3c, 0x0b6b, 0x6f18, 0x78ab, 0x616b, 0x0001, 0x0019, 0x0001, 0x0002, 0x0019, 0x0002, 0x0022, 0x0022, 0x0022, 0x0041, 0x0442, 0x0041, 0x0441, + 0x0841, 0x0001, 0x0821, 0x0841, 0x0422, 0x0041, 0x0041, 0x0002, 0x0441, 0x0041, 0x0841, 0x0025, 0x0002, 0x0005, 0x0861, 0x0022, 0x0022, 0x0c22, 0x0441, 0x0041, + 0x0002, 0x0422, 0x0022, 0x0001, 0x0041, 0x0002, 0x0005, 0x0002, 0x0004, 0x001b, 0x0004, 0x001b, 0x0004, 0x001b, 0x009b, 0x001b, 0x0006, 0x0041, 0x0764, 0x4622, + 0x0844, 0x0702, 0x0011, 0x001b, 0x0701, 0x0221, 0x0041, 0x0001, 0x0011, 0x0001, 0x0002, 0x0442, 0x0001, 0x0002, 0x0022, 0x0002, 0x6441, 0x0001, 0x0002, 0x0001, + 0x0002, 0x0022, 0x001c, 0x0006, 0x0007, 0x0041, 0x0041, 0x0022, 0x0011, 0x0001, 0x1231, 0x0018, 0x0002, 0x4698, 0x7391, 0x023a, 0x0006, 0x0014, 0x1b06, 0x0011, + 0x0005, 0x0011, 0x0005, 0x0018, 0x0011, 0x0010, 0x0019, 0x6b18, 0x001c, 0x0006, 0x4618, 0x0018, 0x0005, 0x0004, 0x0005, 0x0006, 0x0009, 0x0018, 0x18a5, 0x0005, + 0x0305, 0x0006, 0x0390, 0x0006, 0x1086, 0x0386, 0x0006, 0x0005, 0x0009, 0x0005, 0x7385, 0x0018, 0x1611, 0x0006, 0x0005, 0x0006, 0x0011, 0x0005, 0x0006, 0x0005, + 0x0011, 0x0009, 0x0005, 0x0006, 0x7084, 0x0018, 0x4624, 0x6b46, 0x0005, 0x0006, 0x0004, 0x0006, 0x10c6, 0x0086, 0x0006, 0x0011, 0x0018, 0x0011, 0x0005, 0x0006, + 0x6231, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0006, 0x0010, 0x0006, 0x0008, 0x0005, 0x0106, 0x0005, 0x0008, 0x0006, 0x0008, 0x1908, 0x0005, 0x0006, + 0x0005, 0x0006, 0x0018, 0x0009, 0x0098, 0x0005, 0x2106, 0x0011, 0x0005, 0x4625, 0x4625, 0x0005, 0x0011, 0x0005, 0x44b1, 0x14b1, 0x44a5, 0x14d1, 0x0008, 0x0006, + 0x2231, 0x4628, 0x14c8, 0x0011, 0x0008, 0x0011, 0x14b1, 0x18c5, 0x0011, 0x0009, 0x0005, 0x001a, 0x000b, 0x175c, 0x44d8, 0x18d1, 0x0228, 0x0005, 0x0011, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0005, 0x44a5, 0x00d1, 0x0008, 0x0006, 0x0011, 0x18d1, 0x18d1, 0x4626, 0x00d1, 0x0011, 0x0005, 0x0225, 0x0011, 0x0009, 0x14c6, 0x18a5, + 0x0018, 0x0011, 0x20c6, 0x0011, 0x0005, 0x44a5, 0x0225, 0x0005, 0x0011, 0x0005, 0x44a5, 0x0005, 0x1a31, 0x0005, 0x0008, 0x0006, 0x44c6, 0x2228, 0x4626, 0x0005, + 0x0011, 0x18a5, 0x4626, 0x0009, 0x0358, 0x0011, 0x0005, 0x0006, 0x20d1, 0x0228, 0x0005, 0x4625, 0x4625, 0x0005, 0x0011, 0x0005, 0x44a5, 0x0005, 0x1a31, 0x0105, + 0x1906, 0x44c6, 0x2111, 0x2111, 0x0006, 0x0011, 0x20c6, 0x0011, 0x14b1, 0x18c5, 0x0011, 0x0009, 0x00bc, 0x000b, 0x0011, 0x14d1, 0x0005, 0x0011, 0x0005, 0x44a5, + 0x44a5, 0x1631, 0x0225, 0x4625, 0x14b1, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x1908, 0x0011, 0x0008, 0x4508, 0x44c8, 0x00b1, 0x0011, 0x0008, 0x0011, 0x0009, + 0x000b, 0x001c, 0x035c, 0x0011, 0x2106, 0x00c8, 0x0005, 0x44a5, 0x0225, 0x0005, 0x0011, 0x0005, 0x0011, 0x18c5, 0x2106, 0x4508, 0x0006, 0x0011, 0x0006, 0x0011, + 0x18d1, 0x0005, 0x0011, 0x18a5, 0x4626, 0x0009, 0x0011, 0x0018, 0x000b, 0x18bc, 0x6108, 0x0005, 0x44a5, 0x0225, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, + 0x20a6, 0x0008, 0x00d1, 0x4508, 0x0006, 0x0011, 0x0008, 0x0011, 0x1625, 0x0006, 0x0011, 0x0009, 0x14b1, 0x0011, 0x0006, 0x0008, 0x0005, 0x44a5, 0x0225, 0x0005, + 0x18c5, 0x0008, 0x0006, 0x0111, 0x4508, 0x14c8, 0x463c, 0x1631, 0x20a5, 0x000b, 0x0005, 0x0006, 0x0011, 0x0009, 0x000b, 0x001c, 0x0005, 0x20d1, 0x0228, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0005, 0x44b1, 0x0005, 0x0011, 0x1a31, 0x2231, 0x1908, 0x44c6, 0x0011, 0x0008, 0x0011, 0x0009, 0x2231, 0x0308, 0x0011, 0x0005, 0x18a5, + 0x0006, 0x0011, 0x001a, 0x0005, 0x0004, 0x0006, 0x0018, 0x0009, 0x0018, 0x0011, 0x14b1, 0x0011, 0x0005, 0x0011, 0x0005, 0x0225, 0x0005, 0x18a5, 0x0006, 0x4625, + 0x0005, 0x0091, 0x0006, 0x0011, 0x0009, 0x0011, 0x0005, 0x0011, 0x0005, 0x001c, 0x0018, 0x731c, 0x18dc, 0x001c, 0x0009, 0x000b, 0x00dc, 0x02d5, 0x0008, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0006, 0x0008, 0x0006, 0x60c6, 0x0005, 0x0006, 0x0011, 0x0006, 0x0011, 0x001c, 0x0006, 0x001c, 0x479c, 0x0018, 0x001c, 0x0018, 0x0011, + 0x0005, 0x0008, 0x0006, 0x0008, 0x0006, 0x20c6, 0x18c8, 0x0005, 0x0009, 0x0018, 0x0005, 0x1908, 0x14a6, 0x18a5, 0x14c6, 0x0008, 0x0005, 0x0008, 0x0005, 0x0006, + 0x0005, 0x2106, 0x0006, 0x0008, 0x14c8, 0x0009, 0x0008, 0x7386, 0x0001, 0x0221, 0x0011, 0x0631, 0x0002, 0x0098, 0x0002, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, + 0x0225, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0225, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0006, 0x0018, 0x000b, 0x0011, 0x0005, 0x001c, 0x0011, 0x0001, 0x0011, 0x0002, 0x5231, 0x0005, 0x031c, 0x0005, 0x000c, 0x0005, 0x02d5, + 0x0011, 0x0005, 0x0018, 0x000a, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0006, 0x0011, 0x0005, 0x0006, 0x0018, 0x0011, 0x0005, 0x0006, 0x0011, 0x0005, 0x44a5, + 0x0225, 0x0006, 0x0011, 0x0005, 0x20c6, 0x0006, 0x0008, 0x1908, 0x0006, 0x0018, 0x1318, 0x1758, 0x4626, 0x0009, 0x0011, 0x000b, 0x0011, 0x0018, 0x5318, 0x1b18, + 0x40c6, 0x0011, 0x0009, 0x0011, 0x0005, 0x0004, 0x0005, 0x0011, 0x0005, 0x0006, 0x0005, 0x00c5, 0x0011, 0x0005, 0x0011, 0x0005, 0x18d1, 0x2106, 0x1908, 0x2106, + 0x4628, 0x2231, 0x00c8, 0x0008, 0x0006, 0x0011, 0x7231, 0x6311, 0x0009, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0009, 0x000b, 0x0011, + 0x001c, 0x0005, 0x20c6, 0x44c8, 0x6311, 0x0005, 0x00c8, 0x0006, 0x0226, 0x20c8, 0x0006, 0x0008, 0x0006, 0x4626, 0x0009, 0x0011, 0x0009, 0x0011, 0x0018, 0x0004, + 0x0018, 0x0011, 0x0006, 0x1cc6, 0x0011, 0x0006, 0x0008, 0x0005, 0x0106, 0x0006, 0x0106, 0x0008, 0x1908, 0x0005, 0x0011, 0x0009, 0x0018, 0x001c, 0x0006, 0x001c, + 0x0011, 0x20c6, 0x0005, 0x18c8, 0x20c6, 0x18c8, 0x14a6, 0x0009, 0x0005, 0x1906, 0x1908, 0x0006, 0x0008, 0x0011, 0x0018, 0x0005, 0x0008, 0x0006, 0x0008, 0x0006, + 0x0011, 0x0018, 0x0009, 0x0011, 0x0005, 0x0009, 0x0005, 0x0004, 0x0018, 0x0002, 0x0011, 0x0001, 0x0011, 0x0001, 0x0018, 0x0011, 0x0006, 0x0018, 0x0006, 0x0008, + 0x0006, 0x0005, 0x0006, 0x0005, 0x18a5, 0x18c8, 0x0005, 0x0011, 0x0002, 0x0004, 0x0002, 0x0004, 0x0002, 0x0004, 0x0006, 0x0011, 0x0006, 0x0041, 0x0002, 0x0022, + 0x0002, 0x0001, 0x0002, 0x0011, 0x0001, 0x0011, 0x0002, 0x0001, 0x0002, 0x0001, 0x0002, 0x0011, 0x0001, 0x0011, 0x0002, 0x0031, 0x0002, 0x0001, 0x0002, 0x0011, + 0x0002, 0x0003, 0x0002, 0x0003, 0x0002, 0x0003, 0x0002, 0x4442, 0x0001, 0x0b63, 0x001b, 0x0002, 0x4442, 0x0001, 0x6f63, 0x085b, 0x4442, 0x0851, 0x0001, 0x0011, + 0x001b, 0x0002, 0x0001, 0x001b, 0x0a31, 0x4442, 0x0001, 0x6f63, 0x0011, 0x000c, 0x0010, 0x0014, 0x0018, 0x57dd, 0x57dd, 0x0018, 0x01cd, 0x0010, 0x000c, 0x0018, + 0x03dd, 0x0018, 0x5ef8, 0x6718, 0x02d5, 0x0018, 0x5f19, 0x0018, 0x000c, 0x0010, 0x0011, 0x0010, 0x008b, 0x0011, 0x000b, 0x0019, 0x12d5, 0x000b, 0x0019, 0x46d5, + 0x0004, 0x0011, 0x001a, 0x0011, 0x0006, 0x0007, 0x0006, 0x0007, 0x0006, 0x0011, 0x079c, 0x079c, 0x0422, 0x0841, 0x0821, 0x703c, 0x0019, 0x0001, 0x001c, 0x003c, + 0x0001, 0x005c, 0x0001, 0x0002, 0x0005, 0x7382, 0x0422, 0x0019, 0x0001, 0x0002, 0x033c, 0x005c, 0x000b, 0x000a, 0x0041, 0x000a, 0x738b, 0x0011, 0x0019, 0x001c, + 0x0019, 0x001c, 0x679c, 0x001c, 0x0019, 0x001c, 0x673c, 0x033c, 0x001c, 0x0019, 0x001c, 0x02d5, 0x001c, 0x0019, 0x001c, 0x02d5, 0x001c, 0x0019, 0x001c, 0x0019, + 0x001c, 0x0019, 0x001c, 0x0011, 0x001c, 0x0011, 0x000b, 0x001c, 0x000b, 0x001c, 0x0019, 0x001c, 0x0019, 0x001c, 0x0019, 0x001c, 0x0019, 0x001c, 0x02d5, 0x000b, + 0x001c, 0x0019, 0x02d5, 0x0019, 0x02d5, 0x0019, 0x001c, 0x0019, 0x02d5, 0x0019, 0x02d5, 0x0019, 0x02d5, 0x0019, 0x001c, 0x0019, 0x001c, 0x0019, 0x001c, 0x0011, + 0x001c, 0x0011, 0x001c, 0x0001, 0x0011, 0x0002, 0x0622, 0x0001, 0x0002, 0x0022, 0x0001, 0x0822, 0x0002, 0x0004, 0x0001, 0x0041, 0x0002, 0x001c, 0x0041, 0x0006, + 0x0041, 0x0011, 0x0018, 0x2f18, 0x0002, 0x0222, 0x0011, 0x0a31, 0x0005, 0x0011, 0x0304, 0x0011, 0x0006, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0006, 0x0018, 0x03dd, 0x0018, 0x7bb8, 0x0018, 0x5318, 0x7bb8, 0x7bb8, + 0x02d5, 0x0018, 0x0004, 0x0018, 0x0014, 0x0018, 0x5714, 0x0018, 0x7398, 0x0011, 0x001c, 0x0011, 0x001c, 0x0011, 0x001c, 0x0011, 0x001c, 0x0011, 0x630c, 0x1398, + 0x0145, 0x02d5, 0x001c, 0x02d5, 0x52d5, 0x0396, 0x000a, 0x0006, 0x5108, 0x0004, 0x2b9c, 0x114a, 0x7305, 0x023c, 0x0005, 0x1a31, 0x6f66, 0x1484, 0x0014, 0x0005, + 0x1098, 0x00a4, 0x0011, 0x0005, 0x0011, 0x0005, 0x7391, 0x000b, 0x001c, 0x0005, 0x001c, 0x0011, 0x0005, 0x001c, 0x0011, 0x000b, 0x001c, 0x000b, 0x001c, 0x000b, + 0x001c, 0x000b, 0x001c, 0x000b, 0x001c, 0x0005, 0x001c, 0x0005, 0x0011, 0x0005, 0x0004, 0x0005, 0x0011, 0x001c, 0x0011, 0x0005, 0x0004, 0x0018, 0x0005, 0x0004, + 0x0018, 0x0005, 0x0009, 0x0005, 0x0011, 0x0041, 0x1cc5, 0x60e7, 0x0006, 0x0098, 0x0041, 0x0004, 0x0006, 0x0005, 0x000a, 0x0006, 0x0018, 0x0011, 0x001b, 0x0004, + 0x001b, 0x0041, 0x0002, 0x0022, 0x0004, 0x0002, 0x0022, 0x0041, 0x6f64, 0x0041, 0x0025, 0x0822, 0x0022, 0x0001, 0x0002, 0x0001, 0x0041, 0x0011, 0x0441, 0x0821, + 0x0002, 0x0011, 0x1441, 0x0884, 0x0005, 0x00c5, 0x18a5, 0x18a5, 0x0005, 0x1908, 0x0106, 0x001c, 0x0006, 0x0011, 0x000b, 0x6b9c, 0x0011, 0x0005, 0x0018, 0x0011, + 0x0008, 0x0005, 0x0008, 0x0006, 0x0011, 0x0018, 0x0009, 0x0011, 0x0006, 0x0005, 0x0018, 0x1705, 0x0006, 0x0009, 0x0005, 0x0006, 0x0018, 0x0005, 0x0006, 0x0008, + 0x0011, 0x0018, 0x0005, 0x0011, 0x0006, 0x0008, 0x0005, 0x2106, 0x0006, 0x0008, 0x0006, 0x0008, 0x0018, 0x0091, 0x0009, 0x0011, 0x0018, 0x0005, 0x0086, 0x0005, + 0x0009, 0x0005, 0x0011, 0x0005, 0x0006, 0x2106, 0x2106, 0x0006, 0x0011, 0x0005, 0x0006, 0x0005, 0x0106, 0x0011, 0x0009, 0x0011, 0x0018, 0x0005, 0x0004, 0x0005, + 0x001c, 0x1905, 0x0008, 0x0005, 0x18a6, 0x14a6, 0x0006, 0x0005, 0x18c5, 0x0005, 0x0011, 0x10a5, 0x0018, 0x0005, 0x18c8, 0x6308, 0x1085, 0x00c8, 0x0011, 0x0005, + 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0002, 0x001b, 0x0004, 0x0002, 0x6f64, 0x0011, 0x0002, 0x0005, 0x1908, 0x1918, 0x0011, + 0x0009, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0013, 0x0012, 0x0005, 0x0011, 0x0005, 0x0011, 0x0002, 0x0011, 0x0002, 0x0011, 0x00c5, 0x0005, + 0x0019, 0x0005, 0x0011, 0x0005, 0x0011, 0x1625, 0x0005, 0x001b, 0x0011, 0x0005, 0x02b6, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x039a, 0x0011, 0x0006, + 0x0018, 0x5ab8, 0x0011, 0x0006, 0x5298, 0x0017, 0x02d5, 0x5718, 0x6316, 0x5f18, 0x62f7, 0x4718, 0x5318, 0x02d5, 0x0018, 0x6699, 0x0239, 0x6358, 0x0011, 0x0005, + 0x0011, 0x0005, 0x4231, 0x0018, 0x6b18, 0x5ab8, 0x5319, 0x0018, 0x0009, 0x0018, 0x0019, 0x0018, 0x0001, 0x5b15, 0x02fb, 0x0002, 0x5b35, 0x0019, 0x62d5, 0x0018, + 0x0005, 0x0004, 0x0005, 0x0004, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x0011, 0x0005, 0x4625, 0x44a5, 0x6a31, 0x6f3a, 0x6b5c, 0x0391, 0x0019, 0x001c, 0x0011, + 0x0010, 0x001c, 0x0011, +) + + +private fun categoryValueFrom(code: Int, ch: Int): Int { + return when { + code < 0x20 -> code + code < 0x400 -> if ((ch and 1) == 1) code shr 5 else code and 0x1f + else -> + when (ch % 3) { + 2 -> code shr 10 + 1 -> (code shr 5) and 0x1f + else -> code and 0x1f + } + } +} + +/** + * Returns the Unicode general category of this character as an Int. + */ +internal fun Char.getCategoryValue(): Int { + val ch = this.toInt() + + val index = binarySearchRange(rangeStart, ch) + val start = rangeStart[index] + val code = rangeCategory[index] + val value = categoryValueFrom(code, ch - start) + + return if (value == 17) CharCategory.UNASSIGNED.value else value +} diff --git a/kotlin-native/runtime/src/main/kotlin/generated/_DigitChars.kt b/kotlin-native/runtime/src/main/kotlin/generated/_DigitChars.kt new file mode 100644 index 00000000000..ac793a85af0 --- /dev/null +++ b/kotlin-native/runtime/src/main/kotlin/generated/_DigitChars.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.text + +// +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt +// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib +// + +// 37 ranges totally +@SharedImmutable +private val rangeStart = intArrayOf( + 0x0030, 0x0660, 0x06f0, 0x07c0, 0x0966, 0x09e6, 0x0a66, 0x0ae6, 0x0b66, 0x0be6, 0x0c66, 0x0ce6, 0x0d66, 0x0de6, 0x0e50, 0x0ed0, 0x0f20, 0x1040, 0x1090, 0x17e0, + 0x1810, 0x1946, 0x19d0, 0x1a80, 0x1a90, 0x1b50, 0x1bb0, 0x1c40, 0x1c50, 0xa620, 0xa8d0, 0xa900, 0xa9d0, 0xa9f0, 0xaa50, 0xabf0, 0xff10, +) + +internal fun binarySearchRange(array: IntArray, needle: Int): Int { + var bottom = 0 + var top = array.size - 1 + var middle = -1 + var value = 0 + while (bottom <= top) { + middle = (bottom + top) / 2 + value = array[middle] + if (needle > value) + bottom = middle + 1 + else if (needle == value) + return middle + else + top = middle - 1 + } + return middle - (if (needle < value) 1 else 0) +} + +/** + * Returns `true` if this character is a digit. + */ +internal fun Char.isDigitImpl(): Boolean { + val ch = this.toInt() + val index = binarySearchRange(rangeStart, ch) + val high = rangeStart[index] + 9 + return ch <= high +} diff --git a/kotlin-native/runtime/src/main/kotlin/generated/_LetterChars.kt b/kotlin-native/runtime/src/main/kotlin/generated/_LetterChars.kt new file mode 100644 index 00000000000..c18debca831 --- /dev/null +++ b/kotlin-native/runtime/src/main/kotlin/generated/_LetterChars.kt @@ -0,0 +1,130 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.text + +// +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt +// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib +// + +// 222 ranges totally +@SharedImmutable +private val rangeStart = intArrayOf( + 0x0041, 0x0061, 0x00aa, 0x00ba, 0x00c0, 0x00d8, 0x00df, 0x00f8, 0x00ff, 0x0138, 0x0149, 0x0172, 0x0181, 0x0190, 0x019f, 0x01ae, 0x01bd, 0x01cc, 0x01dd, 0x01e9, + 0x01f8, 0x0231, 0x0240, 0x024f, 0x0294, 0x02a3, 0x02b2, 0x02ec, 0x0370, 0x037f, 0x038e, 0x039d, 0x03ac, 0x03c8, 0x03d7, 0x03ee, 0x03fd, 0x0430, 0x045f, 0x048a, + 0x04c1, 0x04cf, 0x0531, 0x0559, 0x0560, 0x05d0, 0x066e, 0x06e5, 0x06ff, 0x074d, 0x07f4, 0x081a, 0x0840, 0x08b6, 0x0950, 0x0985, 0x09aa, 0x09bd, 0x09df, 0x0a05, + 0x0a2a, 0x0a39, 0x0a72, 0x0a93, 0x0ab5, 0x0ae0, 0x0b0f, 0x0b32, 0x0b5c, 0x0b83, 0x0b92, 0x0ba3, 0x0bd0, 0x0c12, 0x0c58, 0x0c85, 0x0caa, 0x0cde, 0x0d04, 0x0d3d, + 0x0d5f, 0x0d9a, 0x0dc0, 0x0e40, 0x0e86, 0x0ea7, 0x0ec0, 0x0f00, 0x0f88, 0x1050, 0x1065, 0x108e, 0x10a0, 0x10bf, 0x10d0, 0x10f1, 0x1100, 0x124a, 0x125a, 0x1290, + 0x12c0, 0x12d8, 0x1380, 0x13a0, 0x13f8, 0x1401, 0x166f, 0x16f1, 0x1720, 0x176e, 0x17dc, 0x1887, 0x1900, 0x1980, 0x1a20, 0x1b45, 0x1bba, 0x1c5a, 0x1c80, 0x1c90, + 0x1cbd, 0x1ce9, 0x1cfa, 0x1d00, 0x1d2c, 0x1d6a, 0x1d79, 0x1d9b, 0x1e00, 0x1e95, 0x1e9d, 0x1f00, 0x1f0f, 0x1f20, 0x1f2f, 0x1f3e, 0x1f4d, 0x1f5d, 0x1f6c, 0x1f7b, + 0x1f8a, 0x1f99, 0x1fa8, 0x1fae, 0x1fbe, 0x1fd0, 0x1fe0, 0x1ff2, 0x2071, 0x2102, 0x210f, 0x2124, 0x2131, 0x2145, 0x2183, 0x2c00, 0x2c30, 0x2c60, 0x2c6f, 0x2c7e, + 0x2c80, 0x2ce4, 0x2cf3, 0x2d00, 0x2d27, 0x2d36, 0x2da0, 0x2db8, 0x2dd0, 0x3005, 0x3041, 0x30fc, 0x31a0, 0x3400, 0x4e00, 0xa000, 0xa4d0, 0xa610, 0xa640, 0xa66e, + 0xa680, 0xa69c, 0xa722, 0xa731, 0xa770, 0xa77f, 0xa78e, 0xa79d, 0xa7ac, 0xa7bb, 0xa7ca, 0xa7f5, 0xa804, 0xa840, 0xa8fb, 0xa930, 0xa9cf, 0xa9fa, 0xaa44, 0xaa7e, + 0xaab9, 0xaadb, 0xab01, 0xab20, 0xab30, 0xab5c, 0xab70, 0xabc0, 0xd7b0, 0xf900, 0xfa70, 0xfb00, 0xfb13, 0xfb22, 0xfb3e, 0xfb4d, 0xfd50, 0xfe70, 0xff21, 0xff41, + 0xff66, 0xffd2, +) + +@SharedImmutable +private val rangeLength = intArrayOf( + 0x001a, 0x001a, 0x000c, 0x0001, 0x0017, 0x0007, 0x0018, 0x0007, 0x0039, 0x0011, 0x0029, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x0011, 0x000c, 0x000f, + 0x0039, 0x000f, 0x000f, 0x0045, 0x000f, 0x000f, 0x0033, 0x0003, 0x000e, 0x000e, 0x000f, 0x000f, 0x001c, 0x000f, 0x0017, 0x000f, 0x0033, 0x002f, 0x0023, 0x0037, + 0x000e, 0x0061, 0x0026, 0x0001, 0x0029, 0x007b, 0x0068, 0x0018, 0x0031, 0x009e, 0x0022, 0x000f, 0x0075, 0x0088, 0x0031, 0x0024, 0x0010, 0x0021, 0x001e, 0x0024, + 0x000f, 0x0026, 0x0020, 0x0021, 0x001c, 0x002d, 0x0022, 0x000c, 0x0016, 0x000e, 0x000e, 0x0017, 0x0041, 0x002c, 0x0029, 0x0024, 0x0014, 0x0015, 0x0037, 0x001a, + 0x0038, 0x0024, 0x0074, 0x0045, 0x0020, 0x0017, 0x0020, 0x006d, 0x00b8, 0x0012, 0x001d, 0x0001, 0x001f, 0x000f, 0x0021, 0x000f, 0x0149, 0x000f, 0x0034, 0x002f, + 0x0017, 0x0083, 0x0010, 0x0056, 0x0006, 0x026c, 0x007c, 0x0021, 0x004d, 0x006a, 0x00a9, 0x006f, 0x0075, 0x0097, 0x0114, 0x006b, 0x0096, 0x0024, 0x0009, 0x002b, + 0x0003, 0x000e, 0x0001, 0x002c, 0x003e, 0x000f, 0x0022, 0x0025, 0x0095, 0x0008, 0x0063, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, + 0x000f, 0x000f, 0x0006, 0x000f, 0x000f, 0x000c, 0x000d, 0x000b, 0x002c, 0x000d, 0x000f, 0x000d, 0x000f, 0x000a, 0x0002, 0x002f, 0x002f, 0x000f, 0x000f, 0x0002, + 0x0064, 0x000f, 0x0001, 0x0026, 0x000f, 0x0061, 0x0017, 0x0017, 0x0060, 0x0038, 0x00ba, 0x0093, 0x0060, 0x19c0, 0x51fd, 0x048d, 0x013d, 0x001c, 0x002e, 0x0012, + 0x001c, 0x0084, 0x000f, 0x003f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x000f, 0x0001, 0x000f, 0x001f, 0x00b8, 0x002b, 0x0083, 0x0021, 0x0049, 0x0037, 0x0039, + 0x000a, 0x001a, 0x0016, 0x000f, 0x002b, 0x000e, 0x0050, 0x2be4, 0x004c, 0x016e, 0x006a, 0x0007, 0x000f, 0x001b, 0x000f, 0x01f1, 0x00ac, 0x008d, 0x001a, 0x001a, + 0x006a, 0x000b, +) + +@SharedImmutable +private val rangeCategory = intArrayOf( + 0x0006, 0x0005, 0x1400003, 0x0007, 0x0006, 0x0006, 0x0005, 0x0005, 0x0019, 0x0019, 0x0019, 0x5599a666, 0x696a699a, 0x5a56a69a, 0x5966999a, 0x6d699a9a, 0x79e7bfd5, 0x0019, 0x0019, 0x699e5999, + 0x0016, 0x5a695559, 0x66666a99, 0x0005, 0x55555557, 0x7d555555, 0x70c0840, 0x0013, 0x15706366, 0x18a88002, 0x6aaaaa9a, 0x6aaaa2aa, 0x0005, 0x56a59555, 0x0019, 0x56986556, 0x0006, 0x0005, 0x0019, 0x0016, + 0x0016, 0x0019, 0x0006, 0x0007, 0x0005, 0x1684086c, 0xe30208, 0x5020e08, 0x812004, 0xc011764, 0x2810808, 0x1811204, 0x1a8b0e64, 0x1b67848, 0x78a0e04, 0x1020420, 0x181021c, 0x6812004, 0x5021c0c, 0x1020818, + 0x73cf3fff, 0x843e04, 0x89200c, 0x870258, 0x9010614, 0x5812e08, 0x960408, 0x1850208, 0x7830208, 0x1860204, 0x1f33c0ff, 0x1830608, 0x886804, 0x190025c, 0xf020a0c, 0x830220, 0x1850228, 0x7820204, 0x830224, 0x2812004, + 0x286300c, 0x890260, 0xb0741c, 0x82741c, 0x980214, 0x4820228, 0xa810214, 0x887e04, 0xa2be614, 0x1840818, 0x2030e08, 0x0007, 0x0006, 0x60022aaa, 0x0005, 0x55c55555, 0x0007, 0x870410, 0xa90410, 0x1040284, + 0x1040204, 0x10402e4, 0x0007, 0x0006, 0x0005, 0x0007, 0x29a0244, 0x8d0e20, 0x7121c48, 0x11b41e0c, 0x3d98604, 0x2810288, 0x11e627c, 0x1b1a08b0, 0x2e81a4d4, 0x69e6e1c, 0x14a434b0, 0x0007, 0x0005, 0x0006, + 0x0006, 0x860210, 0x0007, 0x0005, 0x0007, 0x75555557, 0x0005, 0x0007, 0x0016, 0x0005, 0x0019, 0x6aaa5555, 0x6aa81556, 0x6aaa5555, 0x6aa95556, 0x6aa0555a, 0x62155542, 0x6a955562, 0x555555aa, 0x7d555415, + 0x75555fff, 0x55557fff, 0x0007, 0x7aa5155f, 0x7aa51501, 0x1aa5055, 0x6aa5555, 0x7aa515, 0x8011a04, 0x5a90802, 0x6aa021a9, 0x64aa222, 0x6941ff6a, 0x140156, 0x0016, 0x0006, 0x0005, 0x699996a6, 0x7d55659a, 0x0006, + 0x0016, 0x60198001, 0x0005, 0x0005, 0x7ffc1001, 0x8010ec8, 0x87021c, 0x87021c, 0x2807021c, 0x2855408, 0x830d58, 0xab0a10, 0x6080, 0x0007, 0x0007, 0x0007, 0x04b8, 0x1440, 0x0016, 0x2004, + 0x0016, 0x18c60408, 0x56666666, 0x0019, 0x69995557, 0x660d9999, 0x6666566d, 0x69999999, 0x6666aa6a, 0x66a98199, 0x0005, 0x73fff7f6, 0x840208, 0x1f321cd0, 0x5820204, 0x39d325c, 0x852004, 0xba90214, 0x1972820, 0x18102c8, + 0x810414, 0x38b040c, 0x1060418, 0x021c, 0x0005, 0x1d5555ff, 0x0005, 0x3a8c, 0x085c, 0x0007, 0x0007, 0x0005, 0x7f300155, 0x8d021c, 0x7fff3cf3, 0x4394, 0x14360500, 0x0214, 0x0006, 0x0005, + 0x1060764, 0x0418, +) + + +/** + * Returns `true` if this character is a letter. + */ +internal fun Char.isLetterImpl(): Boolean { + return getLetterType() != 0 +} + +/** + * Returns `true` if this character is a lower case letter. + */ +internal fun Char.isLowerCaseImpl(): Boolean { + return getLetterType() == 1 +} + +/** + * Returns `true` if this character is an upper case letter. + */ +internal fun Char.isUpperCaseImpl(): Boolean { + return getLetterType() == 2 +} + +/** + * Returns + * - `1` if the character is a lower case letter, + * - `2` if the character is an upper case letter, + * - `3` if the character is a letter but not a lower or upper case letter, + * - `0` otherwise. + */ +private fun Char.getLetterType(): Int { + val ch = this.toInt() + val index = binarySearchRange(rangeStart, ch) + + val rangeStart = rangeStart[index] + val rangeEnd = rangeStart + rangeLength[index] - 1 + val code = rangeCategory[index] + + if (ch > rangeEnd) { + return 0 + } + + val lastTwoBits = code and 0x3 + + if (lastTwoBits == 0) { // gap pattern + var shift = 2 + var threshold = rangeStart + for (i in 0..1) { + threshold += (code shr shift) and 0x7f + if (threshold > ch) { + return 3 + } + shift += 7 + threshold += (code shr shift) and 0x7f + if (threshold > ch) { + return 0 + } + shift += 7 + } + return 3 + } + + if (code <= 0x7) { + return lastTwoBits + } + + val distance = (ch - rangeStart) + val shift = if (code <= 0x1F) distance % 2 else distance + return (code shr (2 * shift)) and 0x3 +} diff --git a/kotlin-native/runtime/src/main/kotlin/generated/_WhitespaceChars.kt b/kotlin-native/runtime/src/main/kotlin/generated/_WhitespaceChars.kt new file mode 100644 index 00000000000..fe55745b8bd --- /dev/null +++ b/kotlin-native/runtime/src/main/kotlin/generated/_WhitespaceChars.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.text + +// +// NOTE: THIS FILE IS AUTO-GENERATED by the GenerateUnicodeData.kt +// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib +// + +// 9 ranges totally +/** + * Returns `true` if this character is a whitespace. + */ +internal fun Char.isWhitespaceImpl(): Boolean { + val ch = this.toInt() + return ch in 0x0009..0x000d + || ch in 0x001c..0x0020 + || ch == 0x00a0 + || ch > 0x1000 && ( + ch == 0x1680 + || ch in 0x2000..0x200a + || ch == 0x2028 + || ch == 0x2029 + || ch == 0x202f + || ch == 0x205f + || ch == 0x3000 + ) +} diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Char.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Char.kt index b8b11f70b2d..b787df5e3d4 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Char.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Char.kt @@ -9,27 +9,69 @@ import kotlin.IllegalArgumentException /** * Returns `true` if this character (Unicode code point) is defined in Unicode. + * + * A character is considered to be defined in Unicode if its [category] is not [CharCategory.UNASSIGNED]. */ -@SymbolName("Kotlin_Char_isDefined") -external public fun Char.isDefined(): Boolean +public actual fun Char.isDefined(): Boolean { + if (this < '\u0080') { + return true + } + return getCategoryValue() != CharCategory.UNASSIGNED.value +} /** * Returns `true` if this character is a letter. + * + * A character is considered to be a letter if its [category] is [CharCategory.UPPERCASE_LETTER], + * [CharCategory.LOWERCASE_LETTER], [CharCategory.TITLECASE_LETTER], [CharCategory.MODIFIER_LETTER], or [CharCategory.OTHER_LETTER]. + * + * @sample samples.text.Chars.isLetter */ -@SymbolName("Kotlin_Char_isLetter") -external public fun Char.isLetter(): Boolean +public actual fun Char.isLetter(): Boolean { + if (this in 'a'..'z' || this in 'A'..'Z') { + return true + } + if (this < '\u0080') { + return false + } + return isLetterImpl() +} /** * Returns `true` if this character is a letter or digit. + * + * @see isLetter + * @see isDigit + * + * @sample samples.text.Chars.isLetterOrDigit */ -@SymbolName("Kotlin_Char_isLetterOrDigit") -external public fun Char.isLetterOrDigit(): Boolean +public actual fun Char.isLetterOrDigit(): Boolean { + if (this in 'a'..'z' || this in 'A'..'Z' || this in '0'..'9') { + return true + } + if (this < '\u0080') { + return false + } + + return isDigit() || isLetter() +} /** - * Returns `true` if this character (Unicode code point) is a digit. + * Returns `true` if this character is a digit. + * + * A character is considered to be a digit if its [category] is [CharCategory.DECIMAL_DIGIT_NUMBER]. + * + * @sample samples.text.Chars.isDigit */ -@SymbolName("Kotlin_Char_isDigit") -external public fun Char.isDigit(): Boolean +public actual fun Char.isDigit(): Boolean { + if (this in '0'..'9') { + return true + } + if (this < '\u0080') { + return false + } + return isDigitImpl() +} /** * Returns `true` if this character (Unicode code point) should be regarded as an ignorable @@ -40,28 +82,69 @@ external public fun Char.isIdentifierIgnorable(): Boolean /** * Returns `true` if this character is an ISO control character. + * + * A character is considered to be an ISO control character if its code is in the range `'\u0000'..'\u001F'` or in the range `'\u007F'..'\u009F'`. + * + * @sample samples.text.Chars.isISOControl */ @SymbolName("Kotlin_Char_isISOControl") -external public fun Char.isISOControl(): Boolean +external public actual fun Char.isISOControl(): Boolean /** * Determines whether a character is whitespace according to the Unicode standard. * Returns `true` if the character is whitespace. + * + * @sample samples.text.Chars.isWhitespace */ -@SymbolName("Kotlin_Char_isWhitespace") -external public actual fun Char.isWhitespace(): Boolean +public actual fun Char.isWhitespace(): Boolean = isWhitespaceImpl() /** - * Returns `true` if this character is upper case. + * Returns `true` if this character is an upper case letter. + * + * A character is considered to be an upper case letter if its [category] is [CharCategory.UPPERCASE_LETTER]. + * + * @sample samples.text.Chars.isUpperCase */ -@SymbolName("Kotlin_Char_isUpperCase") -external public fun Char.isUpperCase(): Boolean +public actual fun Char.isUpperCase(): Boolean { + if (this in 'A'..'Z') { + return true + } + if (this < '\u0080') { + return false + } + return isUpperCaseImpl() +} /** - * Returns `true` if this character is lower case. + * Returns `true` if this character is a lower case letter. + * + * A character is considered to be a lower case letter if its [category] is [CharCategory.LOWERCASE_LETTER]. + * + * @sample samples.text.Chars.isLowerCase */ -@SymbolName("Kotlin_Char_isLowerCase") -external public fun Char.isLowerCase(): Boolean +public actual fun Char.isLowerCase(): Boolean { + if (this in 'a'..'z') { + return true + } + if (this < '\u0080') { + return false + } + return isLowerCaseImpl() +} + +/** + * Returns `true` if this character is a title case letter. + * + * A character is considered to be a title case letter if its [category] is [CharCategory.TITLECASE_LETTER]. + * + * @sample samples.text.Chars.isTitleCase + */ +public actual fun Char.isTitleCase(): Boolean { + if (this < '\u0080') { + return false + } + return getCategoryValue() == CharCategory.TITLECASE_LETTER.value +} /** * Converts this character to upper case using Unicode mapping rules of the invariant locale. @@ -152,13 +235,10 @@ internal actual fun digitOf(char: Char, radix: Int): Int = digitOfChecked(char, external internal fun digitOfChecked(char: Char, radix: Int): Int /** - * Returns a value indicating a character's general category. + * Returns the Unicode general category of this character. */ -public val Char.category: CharCategory get() = CharCategory.valueOf(getType()) - -/** Retrun a Unicode category of the character as an Int. */ -@SymbolName("Kotlin_Char_getType") -external internal fun Char.getType(): Int +public actual val Char.category: CharCategory + get() = CharCategory.valueOf(getCategoryValue()) /** * Checks whether the given [radix] is valid radix for string to number and number to string conversion. diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharCategory.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharCategory.kt index 3bdd766f5df..c7def3375de 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharCategory.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/CharCategory.kt @@ -1,13 +1,13 @@ /* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.text /** * Represents the character general category in the Unicode specification. */ -public enum class CharCategory(public val value: Int, public val code: String) { +public actual enum class CharCategory(public val value: Int, public actual val code: String) { /** * General category "Cn" in the Unicode specification. */ @@ -161,14 +161,14 @@ public enum class CharCategory(public val value: Int, public val code: String) { /** * Returns `true` if [char] character belongs to this category. */ - public operator fun contains(char: Char): Boolean = char.getType() == this.value + public actual operator fun contains(char: Char): Boolean = char.getCategoryValue() == this.value public companion object { public fun valueOf(category: Int): CharCategory = - when { - category >=0 && category <= 16 -> values()[category] - category >= 18 && category <= 30 -> values()[category - 1] - else -> throw IllegalArgumentException("Category #$category is not defined.") - } + when (category) { + in 0..16 -> values()[category] + in 18..30 -> values()[category - 1] + else -> throw IllegalArgumentException("Category #$category is not defined.") + } } } \ No newline at end of file