diff options
-rw-r--r-- | mbyte.c | 7 | ||||
-rw-r--r-- | mbyte.h | 1 | ||||
-rw-r--r-- | wcwidth.c | 15 |
3 files changed, 20 insertions, 3 deletions
@@ -70,10 +70,13 @@ size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) int iswprint (wint_t wc) { - return ((0x20 <= wc && wc < 0x7f) || 0xa0 <= wc); + if (Charset_is_utf8) + return ((0x20 <= wc && wc < 0x7f) || 0xa0 <= wc); + else + return (0 <= wc && wc < 256) ? IsPrint(wc) : 0; } -#endif /* HAVE_MBYTE */ +#endif /* !HAVE_WC_FUNCS */ #if !defined(HAVE_MBYTE) || !defined(HAVE_ICONV) @@ -2,6 +2,7 @@ #define _MBYTE_H void mutt_set_charset (char *charset); +extern int Charset_is_utf8; size_t utf8rtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *_ps); @@ -6,6 +6,10 @@ * Markus Kuhn -- 2000-02-08 -- public domain */ +/* Adapted for Mutt by Edmund Grimley Evans. + * wcwidth() now refers to Charset_is_utf8. + */ + #include "mutt.h" #include "mbyte.h" @@ -78,9 +82,18 @@ int wcwidth(wchar_t ucs) int max = sizeof(combining) / sizeof(struct interval) - 1; int mid; - /* test for 8-bit control characters */ if (ucs == 0) return 0; + + /* non-UCS case */ + if (!Charset_is_utf8) { + if (0 <= ucs && ucs < 256) + return IsPrint(wc) ? 1 : -1; + else + return -1; + } + + /* test for 8-bit control characters */ if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0)) return -1; |