diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2010-02-18 23:37:19 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2010-02-18 23:37:19 +0300 |
commit | 7ab414f5a0f46acfaeb621de86f6db0ca648321f (patch) | |
tree | 3e5e7e62c83c3206845b981113db7231a93a6a8a /newlib/libc/ctype/towupper.c | |
parent | 97c8d005d9a7a786e15292719ba8e3f3c6012f5b (diff) |
* libc/ctype/iswalpha.c (iswalpha): Update to Unicode 5.2.
* libc/ctype/iswprint.c (iswprint): Ditto.
* libc/ctype/iswpunct.c (iswpunct): Drop standalone implementation.
Define in terms of other wctype functions instead.
* libc/ctype/towlower.c (towlower): Update to Unicode 5.2. Add comment
to explain how to fetch the data from the Unicode database.
* libc/ctype/towupper.c (towupper): Ditto.
* libc/ctype/utf8alpha.h: Ditto.
* libc/ctype/utf8print.h: Ditto.
* libc/ctype/utf8punct.h: Remove.
* libc/ctype/iswcntrl.c (iswcntrl): Add comment to explain how to
fetch the data from the Unicode database.
Diffstat (limited to 'newlib/libc/ctype/towupper.c')
-rw-r--r-- | newlib/libc/ctype/towupper.c | 272 |
1 files changed, 192 insertions, 80 deletions
diff --git a/newlib/libc/ctype/towupper.c b/newlib/libc/ctype/towupper.c index 945266fea..8b1755b53 100644 --- a/newlib/libc/ctype/towupper.c +++ b/newlib/libc/ctype/towupper.c @@ -71,12 +71,18 @@ _DEFUN(towupper,(c), wint_t c) { #ifdef _MB_CAPABLE c = _jp2uc (c); + /* Based on and tested against Unicode 5.2 */ + + /* Expression used to filter out the characters for the below code: + + awk -F\; '{ if ( $13 != "" ) print $1; }' UnicodeData.txt + */ if (c < 0x100) { if (c == 0x00b5) return 0x039c; - if ((c >= 0x00e0 && c <= 0x00fe) || + if ((c >= 0x00e0 && c <= 0x00fe && c != 0x00f7) || (c >= 0x0061 && c <= 0x007a)) return (c - 0x20); @@ -92,7 +98,8 @@ _DEFUN(towupper,(c), wint_t c) (c >= 0x014b && c <= 0x0177) || (c >= 0x01df && c <= 0x01ef) || (c >= 0x01f9 && c <= 0x021f) || - (c >= 0x0223 && c <= 0x0233)) + (c >= 0x0223 && c <= 0x0233) || + (c >= 0x0247 && c <= 0x024f)) { if (c & 0x01) return (c - 1); @@ -100,7 +107,8 @@ _DEFUN(towupper,(c), wint_t c) } if ((c >= 0x013a && c <= 0x0148) || - (c >= 0x01ce && c <= 0x1dc)) + (c >= 0x01ce && c <= 0x01dc) || + c == 0x023c || c == 0x0242) { if (!(c & 0x01)) return (c - 1); @@ -121,6 +129,9 @@ _DEFUN(towupper,(c), wint_t c) case 0x017f: k = 0x0053; break; + case 0x0180: + k = 0x0243; + break; case 0x0183: k = 0x0182; break; @@ -142,6 +153,9 @@ _DEFUN(towupper,(c), wint_t c) case 0x0199: k = 0x0198; break; + case 0x019a: + k = 0x023d; + break; case 0x019e: k = 0x0220; break; @@ -176,6 +190,21 @@ _DEFUN(towupper,(c), wint_t c) case 0x01f3: k = 0x01f1; break; + case 0x023f: + k = 0x2c7e; + break; + case 0x0240: + k = 0x2c7f; + break; + case 0x0250: + k = 0x2c6f; + break; + case 0x0251: + k = 0x2c6d; + break; + case 0x0252: + k = 0x2c70; + break; case 0x0253: k = 0x0181; break; @@ -206,15 +235,24 @@ _DEFUN(towupper,(c), wint_t c) case 0x0269: k = 0x0196; break; + case 0x026b: + k = 0x2c62; + break; case 0x026f: k = 0x019c; break; + case 0x0271: + k = 0x2c6e; + break; case 0x0272: k = 0x019d; break; case 0x0275: k = 0x019f; break; + case 0x027d: + k = 0x2c64; + break; case 0x0280: k = 0x01a6; break; @@ -224,12 +262,18 @@ _DEFUN(towupper,(c), wint_t c) case 0x0288: k = 0x01ae; break; + case 0x0289: + k = 0x0244; + break; case 0x028a: k = 0x01b1; break; case 0x028b: k = 0x01b2; break; + case 0x028c: + k = 0x0245; + break; case 0x0292: k = 0x01b7; break; @@ -242,86 +286,91 @@ _DEFUN(towupper,(c), wint_t c) } else if (c < 0x0400) { - if (c == 0x03ac) - return 0x0386; - - if ((c & 0xfff0) == 0x03a0 && c >= 0x03ad) - return (c - 0x15); - + wint_t k; + + if (c >= 0x03ad && c <= 0x03af) + return (c - 0x25); + if (c >= 0x03b1 && c <= 0x03cb && c != 0x03c2) return (c - 0x20); - if (c == 0x03c2) - return 0x03a3; - - if (c >= 0x03cc && c <= 0x03f5) + if (c >= 0x03d9 && c <= 0x03ef && (c & 1)) + return (c - 1); + + switch (c) { - wint_t k; - switch (c) - { - case 0x03cc: - k = 0x038c; - break; - case 0x03cd: - case 0x03ce: - k = c - 0x3f; - break; - case 0x03d0: - k = 0x0392; - break; - case 0x03d1: - k = 0x0398; - break; - case 0x03d5: - k = 0x03a6; - break; - case 0x03d6: - k = 0x03a0; - break; - case 0x03d9: - case 0x03db: - case 0x03dd: - case 0x03df: - case 0x03e1: - case 0x03e3: - case 0x03e5: - case 0x03e7: - case 0x03e9: - case 0x03eb: - case 0x03ed: - case 0x03ef: - k = c - 1; - break; - case 0x03f0: - k = 0x039a; - break; - case 0x03f1: - k = 0x03a1; - break; - case 0x03f2: - k = 0x03a3; - break; - case 0x03f5: - k = 0x0395; - break; - default: - k = 0; - } - if (k != 0) - return k; + case 0x0345: + k = 0x0399; + break; + case 0x0371: + case 0x0373: + case 0x0377: + case 0x03f8: + case 0x03fb: + k = c - 1; + break; + case 0x037b: + case 0x037c: + case 0x037d: + k = c + 0x82; + break; + case 0x03ac: + k = 0x0386; + break; + case 0x03c2: + k = 0x03a3; + break; + case 0x03cc: + k = 0x038c; + break; + case 0x03cd: + case 0x03ce: + k = c - 0x3f; + break; + case 0x03d0: + k = 0x0392; + break; + case 0x03d1: + k = 0x0398; + break; + case 0x03d5: + k = 0x03a6; + break; + case 0x03d6: + k = 0x03a0; + break; + case 0x03d7: + k = 0x03cf; + break; + case 0x03f0: + k = 0x039a; + break; + case 0x03f1: + k = 0x03a1; + break; + case 0x03f2: + k = 0x03f9; + break; + case 0x03f5: + k = 0x0395; + break; + default: + k = 0; } + if (k != 0) + return k; } else if (c < 0x500) { - if (c >= 0x0450 && c <= 0x045f) - return (c - 0x50); - if (c >= 0x0430 && c <= 0x044f) return (c - 0x20); + if (c >= 0x0450 && c <= 0x045f) + return (c - 0x50); + if ((c >= 0x0461 && c <= 0x0481) || (c >= 0x048b && c <= 0x04bf) || - (c >= 0x04d1 && c <= 0x04f5)) + (c >= 0x04d1 && c <= 0x04ff)) { if (c & 0x01) return (c - 1); @@ -335,23 +384,36 @@ _DEFUN(towupper,(c), wint_t c) return c; } - if (c == 0x04f9) - return 0x04f8; + if (c == 0x04cf) + return 0x04c0; + + if (c >= 0x04f7 && c <= 0x04f9) + return (c - 1); + } + else if (c < 0x0600) + { + if (c >= 0x0501 && c <= 0x0525 && (c & 1)) + return c - 1; + + if (c >= 0x0561 && c <= 0x0586) + return (c - 0x30); } else if (c < 0x1f00) { - if ((c >= 0x0501 && c <= 0x050f) || - (c >= 0x1e01 && c <= 0x1e95) || - (c >= 0x1ea1 && c <= 0x1ef9)) + if (c == 0x1d79) + return 0xa77d; + + if (c == 0x1d7d) + return 0x2c63; + + if ((c >= 0x1e01 && c <= 0x1e95) || + (c >= 0x1ea1 && c <= 0x1eff)) { if (c & 0x01) return (c - 1); return c; } - if (c >= 0x0561 && c <= 0x0586) - return (c - 0x30); - if (c == 0x1e9b) return 0x1e60; } @@ -407,6 +469,9 @@ _DEFUN(towupper,(c), wint_t c) case 0x1f75: k = 0x1fcb; break; + case 0x1fc3: + k = 0x1fcc; + break; case 0x1fd0: k = 0x1fd8; break; @@ -456,18 +521,65 @@ _DEFUN(towupper,(c), wint_t c) return k; } } - else + else if (c < 0x3000) { + if (c == 0x214e) + return 0x2132; + + if (c == 0x2184) + return 0x2183; + if (c >= 0x2170 && c <= 0x217f) return (c - 0x10); if (c >= 0x24d0 && c <= 0x24e9) return (c - 0x1a); + if (c >= 0x2c30 && c <= 0x2c5e) + return (c - 0x30); + + if ((c >= 0x2c68 && c <= 0x2c6c && !(c & 1)) || + (c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) || + c == 0x2c73 || c == 0x2c76 || + c == 0x2cec || c == 0x2cee) + return (c - 1); + + if (c >= 0x2c81 && c <= 0x2ce3 && (c & 1)) + return (c - 1); + + if (c >= 0x2d00 && c <= 0x2d25) + return (c - 0x1c60); + + switch (c) + { + case 0x2c61: + return 0x2c60; + case 0x2c65: + return 0x023a; + case 0x2c66: + return 0x023e; + } + } + else if (c >= 0xa000 && c < 0xb000) + { + if (((c >= 0xa641 && c <= 0xa65f) || + (c >= 0xa663 && c <= 0xa66d) || + (c >= 0xa681 && c <= 0xa697) || + (c >= 0xa723 && c <= 0xa72f) || + (c >= 0xa733 && c <= 0xa76f) || + (c >= 0xa77f && c <= 0xa787)) && + (c & 1)) + return (c - 1); + + if (c == 0xa77a || c == 0xa77c || c == 0xa78c) + return (c - 1); + } + else + { if (c >= 0xff41 && c <= 0xff5a) return (c - 0x20); - if (c >= 0x10428 && c <= 0x1044d) + if (c >= 0x10428 && c <= 0x1044f) return (c - 0x28); } return c; |