diff --git a/case_switch/alt/tolower_unicode.c b/case_switch/alt/tolower_unicode.c new file mode 100644 index 0000000..ec1ec44 --- /dev/null +++ b/case_switch/alt/tolower_unicode.c @@ -0,0 +1,397 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../build.h" + +static unsigned int tolower_latin_extended_a(unsigned int uc) { // 0x0100—0x017f + + if ( ( ( (uc >= 0x0100 && uc <= 0x0137) || + (uc >= 0x014a && uc <= 0x0177) ) && !(uc&1) ) || + ( ( (uc >= 0x0139 && uc <= 0x0148) || + (uc >= 0x0179 && uc <= 0x017e) ) && (uc&1) ) + ) return uc + 1; + + switch (uc) { default: break; + case 0x0178: return 0x00ff; + } + + return uc; +} + +static unsigned int tolower_latin_extended_b(unsigned int uc) { // 0x0180—0x024f + #ifndef LATIN_EXTENDED_B_DISABLE + if ( ( ( (uc >= 0x01a0 && uc <= 0x01a5) || + (uc >= 0x01de && uc <= 0x01ef) || + (uc >= 0x01f8 && uc <= 0x01ff) || + (uc >= 0x0200 && uc <= 0x021b) || + (uc >= 0x0222 && uc <= 0x0233) || + (uc >= 0x0246 && uc <= 0x024f) ) && !(uc&1) ) || + ( ( (uc >= 0x0189 && uc <= 0x0192) || + (uc >= 0x01cd && uc <= 0x01dc) ) && (uc&1) ) + ) return uc + 1; + + switch (uc) { default: break; + case 0x01c4: + case 0x01c5: return 0x01c6; + case 0x01c7: + case 0x01c8: return 0x01c9; + case 0x01ca: + case 0x01cb: return 0x01cc; + case 0x01f1: + case 0x01f2: return 0x01f3; + + case 0x01a8: + case 0x01ac: + case 0x01af: + case 0x01b3: + case 0x01b5: + case 0x01b8: + case 0x01bc: + case 0x0182: + case 0x0184: + case 0x0187: + case 0x0198: + case 0x01f4: + case 0x021c: + case 0x021e: + case 0x023b: + case 0x023e: + case 0x0241: return uc + 1; + + case 0x018e: return 0x01dd; + case 0x01f6: return 0x0195; + case 0x0220: return 0x019e; + case 0x023d: return 0x019a; + case 0x0243: return 0x0180; + #ifndef IPA_EXTENSIONS_DISABLE + case 0x0181: return 0x0253; + case 0x0186: return 0x0254; + case 0x0190: return 0x025b; + case 0x0193: return 0x0260; + case 0x0194: return 0x0263; + case 0x0196: return 0x0269; + case 0x0197: return 0x0268; + case 0x019c: return 0x026f; + case 0x019d: return 0x0272; + case 0x019f: return 0x0275; + case 0x01a6: return 0x0280; + case 0x01a9: return 0x0283; + case 0x01ae: return 0x0288; + case 0x01b1: return 0x028a; + case 0x01b2: return 0x028b; + case 0x01b7: return 0x0292; + case 0x01bf: return 0x0259; + case 0x01f7: return 0x02bf; + case 0x0244: return 0x0289; + case 0x0245: return 0x028c; + #endif + #ifndef LATIN_EXTENDED_C_DISABLE + case 0x023a: return 0x2c65; + #endif + } + #endif + + return uc; +} + +static unsigned int tolower_latin_extended_c(unsigned int uc) { // 0x2c60—0x2c7f + #ifndef LATIN_EXTENDED_C_DISABLE + if ( (uc >= 0x2c67 && uc <= 0x2c6c) && (uc&1) ) + return uc + 1; + + switch (uc) { default: break; + + case 0x2c72: + case 0x2c60: return uc + 1; + + #ifndef IPA_EXTENSIONS_DISABLE + case 0x2c62: return 0x026b; + case 0x2c64: return 0x027d; + case 0x2c6d: return 0x0251; + case 0x2c6e: return 0x0271; + case 0x2c6f: return 0x0250; + case 0x2c70: return 0x0252; + #endif + #ifndef PHONETIC_EXTENSIONS_DISABLE + case 0x2c63: return 0x1d7d; + #endif + #ifndef LATIN_EXTENDED_B_DISABLE + case 0x2c7e: return 0x023f; + case 0x2c7f: return 0x0240; + #endif + } + #endif + + return uc; +} + +static unsigned int tolower_latin_extended_d(unsigned int uc) { // 0xa720—0xa7ff + #ifndef LATIN_EXTENDED_D_DISABLE + if ( ( ( (uc >= 0xa796 && uc <= 0xa7a9) || + (uc >= 0xa7b4 && uc <= 0xa7bf) || + (uc >= 0xa722 && uc <= 0xa72f) || + (uc >= 0xa732 && uc <= 0xa76f) || + (uc >= 0xa77e && uc <= 0xa787) ) && !(uc&1) ) + ) return uc + 1; + + switch (uc) { default: break; + + case 0xa779: + case 0xa77b: + case 0xa790: + case 0xa792: + case 0xa7c2: + case 0xa7c7: + case 0xa7c9: return uc + 1; + + #ifndef PHONETIC_EXTENSIONS_DISABLE + case 0xa77d: return 0x1d79; + #endif + #ifndef IPA_EXTENSIONS_DISABLE + case 0xa78d: return 0x0265; + case 0xa7aa: return 0x0266; + case 0xa7ab: return 0x025c; + case 0xa7ac: return 0x0261; + case 0xa7ad: return 0x026c; + case 0xa7ae: return 0x026a; + case 0xa7b1: return 0x0287; + case 0xa7b2: return 0x029d; + case 0xa7b0: return 0x029e; + #endif + #ifndef LATIN_EXTENDED_E_DISABLE + case 0xa7b3: return 0xab53; + #endif + } + #endif + + return uc; +} + +static unsigned int tolower_latin_extended_additional(unsigned int uc) { // 0x1e00-0x1eff + #ifndef LATIN_EXTENDED_ADDITIONAL_DISABLE + if ( ( ( (uc >= 0x1e00 && uc <= 0x1e95) || + (uc >= 0x1ea0 && uc <= 0x1eff) ) && !(uc&1) ) + ) return uc + 1; + + switch (uc) { default: break; + case 0x1e9e: return 0x00df; + } + #endif + + return uc; +} + +static unsigned int tolower_greek_and_coptic(unsigned int uc) { // 0x0370-0x03ff + + if ((uc >= 0x0391 && uc <= 0x03a1) || (uc >= 0x03a4 && uc <= 0x03ab)) { + return uc + 0x20; + } + + if (uc >= 0x03d8 && uc <= 0x03ef && !(uc&1)) { + return uc + 1; + } + + switch (uc) { default: return uc; + case 0x0388: + case 0x0389: + case 0x038a: return uc + 0x25; + + case 0x038e: + case 0x038f: --uc; + case 0x038c: return uc + 0x40; + + case 0x03fd: + case 0x03fe: + case 0x03ff: return uc - 0x82; + + case 0x0370: + case 0x0372: + case 0x0376: + case 0x03f7: + case 0x03fa: return uc + 1; + + case 0x037f: return 0x03f3; + case 0x0386: return 0x03ac; + case 0x03f9: return 0x03f2; + case 0x03f4: return 0x03b8; + case 0x03a3: return 0x03c3; + } +} + +static unsigned int tolower_greek_extended(unsigned int uc) { // 0x1f00-0x1fff + #ifndef GREEK_EXTENDED_DISABLE + if (((uc >= 0x1f00 && uc <= 0x1f6f) || (uc >= 0x1f80 && uc <= 0x1faf)) && (uc&0x08)) { + switch (uc) { default: break; + case 0x1f1e: + case 0x1f1f: + case 0x1f4e: + case 0x1f4f: + case 0x1f58: + case 0x1f5a: + case 0x1f5c: + case 0x1f5e: return uc; + } + + return uc ^ 0x08; + } + + switch (uc) { default: break; + + case 0x1fba: + case 0x1fbb: return uc - 0x4a; + + case 0x1fc8: + case 0x1fc9: + case 0x1fca: + case 0x1fcb: return uc - 0x56; + + case 0x1fda: + case 0x1fdb: return uc - 0x64; + + case 0x1fea: + case 0x1feb: uc ^= 0x10; + case 0x1ff8: + case 0x1ff9: return uc ^ 0x80; + + case 0x1fb8: + case 0x1fb9: + case 0x1fe8: + case 0x1fe9: + case 0x1fd8: + case 0x1fd9: return uc ^ 0x08; + + case 0x1ffa: + case 0x1ffb: return uc - 0x7e; + + case 0x1fec: uc += 2; + case 0x1fcc: + case 0x1ffc: return uc - 0x09; + } + #endif + + return uc; +} + +static unsigned int tolower_exclusions(unsigned int uc) { + + switch (uc) { default: break; + case 0x04c0: return 0x04cf; + + case 0x1cbd: return 0x10fd; + case 0x1cbe: return 0x10fe; + case 0x1cbf: return 0x10ff; + #ifndef COPTIC_DISABLE + case 0x2cf2: + case 0x2ceb: + case 0x2ced: return uc + 1; + #endif + } + + if (uc >= 0x0460 && uc <= 0x0481 && !(uc&1)) { // Cyrillic + return uc + 1; + } + + if (uc >= 0x048a && uc <= 0x04bf && !(uc&1)) { // Cyrillic + return uc + 1; + } + + if (uc >= 0x04c1 && uc <= 0x04ce && (uc&1)) { // Cyrillic + return uc + 1; + } + + if (uc >= 0x04d0 && uc <= 0x04ff && !(uc&1)) { // Cyrillic + return uc + 1; + } + #ifndef CYRILLIC_SUPLEMENT_DISABLE + if (uc >= 0x0500 && uc <= 0x052f && !(uc&1)) { // Cyrillic Supplement + return uc + 1; + } + #endif + #ifndef CYRILLIC_EXTENDED_B_DISABLE + if (uc >= 0xa640 && uc <= 0xa66d && !(uc&1)) { // Cyrillic Extended-B + return uc + 1; + } + + if (uc >= 0xa680 && uc <= 0xa69b && !(uc&1)) { // Cyrillic Extended-B + return uc + 1; + } + #endif + + if (uc >= 0x0531 && uc <= 0x0556) { // Armenian + return uc + 0x30; + } + + if ((uc >= 0x10a0 && uc <= 0x10c5) || uc == 0x10c7 || uc == 0x10cd) { // Georgian + return uc + 0x1c60; + } + + if (uc >= 0x1c90 && uc <= 0x1cba) { // Georgian Extended + return uc - 0x0bc0; + } + #ifndef CHEROKEE_DISABLE + if (uc >= 0x13a0 && uc <= 0x13ef) { // Cherokee + return uc + 0x97d0; + } + if (uc >= 0x13f0 && uc <= 0x13f5) { // Cherokee + return uc | 0x08; + } + #endif + #ifndef GLAGOLITIC_DISABLE + if (uc >= 0x2c00 && uc <= 0x2c2e) { // Glagolitic + return uc + 0x30; + } + #endif + #ifndef COPTIC_DISABLE + if (uc >= 0x2c80 && uc <= 0x2ce3 && !(uc&1)) { // Coptic + return uc + 1; + } + #endif + #ifndef DESERET_DISABLE + if (uc >= 0x10400 && uc <= 0x10427) { // Deseret + return uc + 0x28; + } + #endif + #ifndef OSAGE_DISABLE + if (uc >= 0x104b0 && uc <= 0x104d3) { // Osage + return uc + 0x28; + } + #endif + #ifndef OLD_HUNGARIAN_DISABLE + if (uc >= 0x10c80 && uc <= 0x10cb2) { // Old Hungarian + return uc | 0x40; + } + #endif + #ifndef WARANG_CITI_DISABLE + if (uc >= 0x118a0 && uc <= 0x118bf) { // Warang Citi + return uc | 0x60; + } + #endif + + return uc; +} + +unsigned int tolower_unicode(unsigned int uc) { + + if (uc >= 0x41 && uc <= 0x5a || (uc >= 0xc0 && uc <= 0xde && uc != 0xd7)) { + return uc | 0x20; + } + + if (uc >= 0x0410 && uc <= 0x042f) { // Cyrillic + return uc + 0x20; + } + + if (uc >= 0x0400 && uc <= 0x040f) { // Cyrillic + return uc + 0x50; + } + + if (uc >= 0x0370 && uc <= 0x03ff) return tolower_greek_and_coptic(uc); + if (uc >= 0x1f00 && uc <= 0x1fff) return tolower_greek_extended(uc); + + if (uc >= 0x0100 && uc <= 0x017f) return tolower_latin_extended_a(uc); + if (uc >= 0x0180 && uc <= 0x024f) return tolower_latin_extended_b(uc); + if (uc >= 0x2c60 && uc <= 0x2c7f) return tolower_latin_extended_c(uc); + if (uc >= 0xa720 && uc <= 0xa7ff) return tolower_latin_extended_d(uc); + if (uc >= 0x1e00 && uc <= 0x1eff) return tolower_latin_extended_additional(uc); + + return tolower_exclusions(uc); +} diff --git a/case_switch/alt/toupper_unicode.c b/case_switch/alt/toupper_unicode.c new file mode 100644 index 0000000..f7274cb --- /dev/null +++ b/case_switch/alt/toupper_unicode.c @@ -0,0 +1,432 @@ +/* This software is licensed by the MIT License, see LICENSE file */ +/* Copyright © 2022 Gregory Lirent */ + +#include "../../build.h" + +static unsigned int toupper_latin_extended_a(unsigned int uc) { // 0x0100—0x017f + + if ( ( ( (uc >= 0x0100 && uc <= 0x0137) || + (uc >= 0x014a && uc <= 0x0177) ) && (uc&1) ) || + ( ( (uc >= 0x0139 && uc <= 0x0148) || + (uc >= 0x0179 && uc <= 0x017e) ) && !(uc&1) ) + ) return uc - 1; + + return uc; +} + +static unsigned int toupper_latin_extended_b(unsigned int uc) { // 0x0180—0x024f + + #ifndef LATIN_EXTENDED_B_DISABLE + if ( ( ( (uc >= 0x01a0 && uc <= 0x01a5) || + (uc >= 0x01de && uc <= 0x01ef) || + (uc >= 0x01f8 && uc <= 0x01ff) || + (uc >= 0x0200 && uc <= 0x021b) || + (uc >= 0x0222 && uc <= 0x0233) || + (uc >= 0x0246 && uc <= 0x024f) ) && (uc&1) ) || + ( ( (uc >= 0x0189 && uc <= 0x0192) || + (uc >= 0x01cd && uc <= 0x01dc) ) && !(uc&1) ) + ) return uc - 1; + + + switch (uc) { default: break; + + case 0x01c6: + case 0x01c9: + case 0x01cc: + case 0x01f3: return uc - 2; // or -1 + + case 0x0183: + case 0x0185: + case 0x0188: + case 0x0199: + case 0x01a7: + case 0x01ad: + case 0x01b0: + case 0x01b4: + case 0x01b6: + case 0x01b9: + case 0x01bd: + case 0x01f5: + case 0x021d: + case 0x021f: + case 0x023c: + case 0x023d: + case 0x0242: return uc - 1; + + case 0x0180: return 0x0243; + case 0x0195: return 0x01f6; + case 0x019a: return 0x023d; + case 0x019e: return 0x0220; + case 0x01dd: return 0x018e; + + #ifndef LATIN_EXTENDED_C_DISABLE + case 0x023f: return 0x2c7e; + case 0x0240: return 0x2c7f; + #endif + } + #endif + + return uc; +} + +static unsigned int toupper_latin_extended_c(unsigned int uc) { // 0x2c60—0x2c7f + #ifndef LATIN_EXTENDED_C_DISABLE + if ( (uc >= 0x2c67 && uc <= 0x2c6c) && !(uc&1) ) + return uc - 1; + + switch (uc) { default: break; + + case 0x2c73: + case 0x2c61: return uc - 1; + + #ifndef LATIN_EXTENDED_B_DISABLE + case 0x2c65: return 0x023a; + #endif + } + #endif + + return uc; +} + +static unsigned int toupper_latin_extended_d(unsigned int uc) { // 0xa720—0xa7ff + #ifndef LATIN_EXTENDED_D_DISABLE + if ( ( ( (uc >= 0xa796 && uc <= 0xa7a9) || + (uc >= 0xa7b4 && uc <= 0xa7bf) || + (uc >= 0xa722 && uc <= 0xa72f) || + (uc >= 0xa732 && uc <= 0xa76f) || + (uc >= 0xa77e && uc <= 0xa787) ) && (uc&1) ) + ) return uc - 1; + + switch (uc) { default: break; + case 0xa7c3: + case 0xa7c8: + case 0xa7ca: + case 0xa791: + case 0xa793: + case 0xa77a: + case 0xa77c: return uc - 1; + } + #endif + + return uc; +} + +static unsigned int toupper_ipa_extensions(unsigned int uc) { // 0x0250-0x02af + #ifndef IPA_EXTENSIONS_DISABLE + switch (uc) { default: break; + #ifndef LATIN_EXTENDED_B_DISABLE + case 0x0259: return 0x01bf; + case 0x025b: return 0x0190; + case 0x0260: return 0x0193; + case 0x0263: return 0x0194; + case 0x0269: return 0x0196; + case 0x0268: return 0x0197; + case 0x026f: return 0x019c; + case 0x0272: return 0x019d; + case 0x0275: return 0x019f; + case 0x0280: return 0x01a6; + case 0x0283: return 0x01a9; + case 0x0288: return 0x01ae; + case 0x028a: return 0x01b1; + case 0x028b: return 0x01b2; + case 0x0292: return 0x01b7; + case 0x02bf: return 0x01f7; + case 0x0253: return 0x0181; + case 0x0254: return 0x0186; + case 0x0289: return 0x0244; + case 0x028c: return 0x0245; + #endif + #ifndef LATIN_EXTENDED_C_DISABLE + case 0x0250: return 0x2c6f; + case 0x0251: return 0x2c6d; + case 0x0252: return 0x2c70; + case 0x026b: return 0x2c62; + case 0x0271: return 0x2c6e; + case 0x027d: return 0x2c64; + #endif + #ifndef LATIN_EXTENDED_D_DISABLE + case 0x025c: return 0xa7ab; + case 0x0261: return 0xa7ac; + case 0x0265: return 0xa78d; + case 0x0266: return 0xa7aa; + case 0x026a: return 0xa7ae; + case 0x026c: return 0xa7ad; + case 0x0287: return 0xa7b1; + case 0x029d: return 0xa7b2; + case 0x029e: return 0xa7b0; + #endif + #ifndef LATIN_EXTENDED_ADDITIONAL_DISABLE + case 0x00df: return 0x1e9e; + #endif + } + #endif + + return uc; +} + +static unsigned int toupper_latin_extended_additional(unsigned int uc) { // 0x1e00-0x1eff + #ifndef LATIN_EXTENDED_ADDITIONAL_DISABLE + if ( ( ( (uc >= 0x1e00 && uc <= 0x1e95) || + (uc >= 0x1ea0 && uc <= 0x1eff) ) && (uc&1) ) + ) return uc - 1; + + switch (uc) { default: break; + case 0x1e9b: return 0x1e60; + } + #endif + + return uc; +} + +static unsigned int toupper_greek_and_coptic(unsigned int uc) { // 0x0370-0x03ff + + if ((uc >= 0x03b1 && uc <= 0x03c1) || (uc >= 0x03c4 && uc <= 0x03cb)) { + return uc - 0x20; + } + + if (uc >= 0x03d8 && uc <= 0x03ef && (uc&1)) { + return uc - 1; + } + + switch (uc) { default: return uc; + case 0x03ad: + case 0x03ae: + case 0x03af: return uc - 0x25; + + case 0x03cd: + case 0x03ce: ++uc; + case 0x03cc: return uc - 0x40; + + case 0x037b: + case 0x037c: + case 0x037d: return uc + 0x82; + + case 0x0371: + case 0x0373: + case 0x0377: + case 0x03f8: + case 0x03fb: return uc - 1; + + case 0x03f3: return 0x037f; + case 0x03ac: return 0x0386; + case 0x03f2: return 0x03f9; + case 0x03f0: return 0x039a; + case 0x03f1: return 0x03a1; + case 0x03f5: return 0x0395; + case 0x03c3: + case 0x03c2: return 0x03a3; + } +} + +static unsigned int toupper_greek_extended(unsigned int uc) { // 0x1f00-0x1fff + #ifndef GREEK_EXTENDED_DISABLE + if (((uc >= 0x1f00 && uc <= 0x1f6f) || (uc >= 0x1f80 && uc <= 0x1faf)) && !(uc&0x08)) { + switch (uc) { default: break; + case 0x1f16: + case 0x1f17: + case 0x1f46: + case 0x1f47: + case 0x1f50: + case 0x1f52: + case 0x1f54: + case 0x1f56: return uc; + } + return uc | 0x08; + } + + switch (uc) { default: break; + case 0x1fbe: return 0x0399; + + case 0x1f70: + case 0x1f71: return uc + 0x4a; + + case 0x1f72: + case 0x1f73: + case 0x1f74: + case 0x1f75: return uc + 0x56; + + case 0x1f76: + case 0x1f77: return uc + 0x64; + + case 0x1f7a: + case 0x1f7b: uc |= 0x10; + case 0x1f78: + case 0x1f79: return uc | 0x80; + + case 0x1fb0: + case 0x1fb1: + case 0x1fe0: + case 0x1fe1: + case 0x1fd0: + case 0x1fd1: return uc | 0x08; + + case 0x1f7c: + case 0x1f7d: return uc + 0x7e; + + case 0x1fe5: uc -= 2; + case 0x1fc3: + case 0x1ff3: return uc + 0x09; + } + #endif + + return uc; +} + +static unsigned int toupper_exclusions(unsigned int uc) { + + switch (uc) { default: break; + case 0x04cf: return 0x04c0; + case 0x00ff: return 0x0178; + + case 0x10fd: return 0x1cbd; + case 0x10fe: return 0x1cbe; + case 0x10ff: return 0x1cbf; + + #if !defined(LATIN_EXTENDED_E_DISABLE) && !defined(LATIN_EXTENDED_D_DISABLE) + case 0xab53: return 0xa7b3; + #endif + #ifndef LATIN_EXTENDED_ADDITIONAL_DISABLE + case 0x00df: return 0x1e9e; + #endif + #ifndef PHONETIC_EXTENSIONS_DISABLE + #ifndef LATIN_EXTENDED_C_DISABLE + case 0x1d7d: return 0x2c63; + #endif + #ifndef LATIN_EXTENDED_D_DISABLE + case 0x1d79: return 0xa77d; + #endif + #endif + + #ifndef CYRILLIC_EXTENDED_C_DISABLE + case 0x1c80: return 0x0412; + case 0x1c81: return 0x0414; + case 0x1c82: return 0x041e; + case 0x1c83: return 0x0421; + case 0x1c84: return 0x0422; + case 0x1c85: return 0x0422; + case 0x1c86: return 0x042a; + case 0x1c87: return 0x0462; + #ifndef CYRILLIC_EXTENDED_B_DISABLE + case 0x1c88: return 0xa64a; + #endif + #endif + + #ifndef COPTIC_DISABLE + case 0x2cf3: + case 0x2cec: + case 0x2cee: return uc - 1; + #endif + } + + if (uc >= 0x0460 && uc <= 0x0481 && (uc&1)) { // Cyrillic + return uc - 1; + } + + if (uc >= 0x048a && uc <= 0x04bf && (uc&1)) { // Cyrillic + return uc - 1; + } + + if (uc >= 0x04c1 && uc <= 0x04ce && !(uc&1)) { // Cyrillic + return uc - 1; + } + + if (uc >= 0x04d0 && uc <= 0x04ff && (uc&1)) { // Cyrillic + return uc - 1; + } + + #ifndef CYRILLIC_SUPLEMENT_DISABLE + if (uc >= 0x0500 && uc <= 0x052f && (uc&1)) { // Cyrillic Supplement + return uc - 1; + } + #endif + #ifndef CYRILLIC_EXTENDED_B_DISABLE + if (uc >= 0xa680 && uc <= 0xa69b && (uc&1)) { // Cyrillic Extended-B + return uc - 1; + } + if (uc >= 0xa640 && uc <= 0xa66d && (uc&1)) { // Cyrillic Extended-B + return uc - 1; + } + #endif + + if (uc >= 0x0561 && uc <= 0x0586) { // Armenian + return uc - 0x30; + } + + if (uc >= 0x10d0 && uc <= 0x10fa) { // Georgian + return uc + 0x0bc0; + } + #ifndef CHEROKEE_DISABLE + if (uc >= 0x13f8 && uc <= 0x13fd) { // Cherokee + return uc ^ 0x08; + } + #endif + #ifndef GLAGOLITIC_DISABLE + if (uc >= 0x2c30 && uc <= 0x2c5e) { // Glagolitic + return uc - 0x30; + } + #endif + #ifndef COPTIC_DISABLE + if (uc >= 0x2c80 && uc <= 0x2ce3 && (uc&1)) { // Coptic + return uc - 1; + } + #endif + #ifndef GEORGIAN_SUPPLEMENT_DISABLE + if ((uc >= 0x2d00 && uc <= 0x2d25) || uc == 0x2d27 || uc == 0x2d2d) { // Georgian Supplement + return uc - 0x1c60; + } + #endif + #ifndef CHEROKEE_DISABLE + if (uc >= 0xab70 && uc <= 0xabbf) { // Cherokee Supplement + return uc - 0x97d0; + } + #endif + #ifndef DESERET_DISABLE + if (uc >= 0x10428 && uc <= 0x1044f) { // Deseret + return uc - 0x28; + } + #endif + #ifndef OSAGE_DISABLE + if (uc >= 0x104d8 && uc <= 0x104fb) { // Osage + return uc - 0x28; + } + #endif + #ifndef OLD_HUNGARIAN_DISABLE + if (uc >= 0x10cc0 && uc <= 0x10cf2) { // Old Hungarian + return uc ^ 0x40; + } + #endif + #ifndef WARANG_CITI_DISABLE + if (uc >= 0x118c0 && uc <= 0x118df) { // Warang Citi + return uc ^ 0x60; + } + #endif + + return uc; +} + +unsigned int toupper_unicode2(unsigned int uc) { + + if (uc >= 0x61 && uc <= 0x7a || (uc >= 0xe0 && uc <= 0xfe && uc != 0xf7)) { + return uc ^ 0x20; + } + + if (uc >= 0x0430 && uc <= 0x044f) { // Cyrillic + return uc - 0x20; + } + + if (uc >= 0x0450 && uc <= 0x045f) { + return uc - 0x50; + } + + if (uc >= 0x0370 && uc <= 0x03ff) return toupper_greek_and_coptic(uc); + if (uc >= 0x1f00 && uc <= 0x1fff) return toupper_greek_extended(uc); + + if (uc >= 0x0100 && uc <= 0x017f) return toupper_latin_extended_a(uc); + if (uc >= 0x0180 && uc <= 0x024f) return toupper_latin_extended_b(uc); + if (uc >= 0x2c60 && uc <= 0x2c7f) return toupper_latin_extended_c(uc); + if (uc >= 0xa720 && uc <= 0xa7ff) return toupper_latin_extended_d(uc); + if (uc >= 0x0250 && uc <= 0x02af) return toupper_ipa_extensions(uc); + if (uc >= 0x1e00 && uc <= 0x1eff) return toupper_latin_extended_additional(uc); + + return toupper_exclusions(uc); +}