X-Git-Url: https://git.llucax.com/software/mutt-debian.git/blobdiff_plain/14c29200cb58d3c4a0830265f2433849781858d0..f0fc6666e528288a25b32d332225d92cd9cbdca0:/mbyte.c diff --git a/mbyte.c b/mbyte.c index 9bc6f5d..6e45024 100644 --- a/mbyte.c +++ b/mbyte.c @@ -64,7 +64,7 @@ void mutt_set_charset (char *charset) } #endif - if (!strcmp(buffer, "utf-8")) + if (mutt_is_utf8 (buffer)) Charset_is_utf8 = 1; #ifndef HAVE_WC_FUNCS else if (!ascii_strcasecmp(buffer, "euc-jp") || !ascii_strcasecmp(buffer, "shift_jis") @@ -285,6 +285,23 @@ static wint_t towupper_ucs (wint_t x) return x; } +static int iswupper_ucs (wint_t x) +{ + /* Only works for x < 0x130 */ + if ((0x60 < x && x < 0x7b) || (0xe0 <= x && x < 0xff && x != 0xf7)) + return 0; + else if ((0x40 < x && x < 0x5b) || (0xbf < x && x < 0xde)) + return 1; + else if (0x100 <= x && x < 0x130) + return 1; + else if (x == 0xb5) + return 1; + else if (x == 0xff) + return 0; + else + return 0; +} + static wint_t towlower_ucs (wint_t x) { /* Only works for x < 0x130 */ @@ -313,6 +330,21 @@ static int iswalnum_ucs (wint_t wc) return !(wc == 0xd7 || wc == 0xf7); } +static int iswalpha_ucs (wint_t wc) +{ + /* Only works for x < 0x220 */ + if (wc >= 0x100) + return 1; + else if (wc < 0x3a) + return 0; + else if (wc < 0xa0) + return (0x40 < (wc & ~0x20) && (wc & ~0x20) < 0x5b); + else if (wc < 0xc0) + return (wc == 0xaa || wc == 0xb5 || wc == 0xba); + else + return !(wc == 0xd7 || wc == 0xf7); +} + wint_t towupper (wint_t wc) { if (Charset_is_utf8 || charset_is_ja) @@ -337,6 +369,22 @@ int iswalnum (wint_t wc) return (0 <= wc && wc < 256) ? isalnum (wc) : 0; } +int iswalpha (wint_t wc) +{ + if (Charset_is_utf8 || charset_is_ja) + return iswalpha_ucs (wc); + else + return (0 <= wc && wc < 256) ? isalpha (wc) : 0; +} + +int iswupper (wint_t wc) +{ + if (Charset_is_utf8 || charset_is_ja) + return iswupper_ucs (wc); + else + return (0 <= wc && wc < 256) ? isupper (wc) : 0; +} + /* * l10n for Japanese: * Symbols, Greek and Cyrillic in JIS X 0208, Japanese Kanji @@ -495,6 +543,7 @@ int mutt_filter_unprintable (char **s) if (k == (size_t)(-1) || k == (size_t)(-2)) { k = 1; + memset (&mbstate1, 0, sizeof (mbstate1)); wc = replacement_char(); } if (!IsWPrint (wc))