From bb2cb98ea13678e1f409e6ebdeee266a0b93fa8e Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 16 Jan 2008 10:39:11 +0100 Subject: [PATCH] Use libncursesw, because UTF-8 does not work otherwise. --- ChangeLog | 8 ++++++++ Makefile | 13 +++++++++++-- README | 2 +- cm.c | 20 ++++++++++++++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f865d92..6116ced 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-01-16 Martin Mares + + * Non-ASCII characters are displayed properly in UTF-8 locale. + Unfortunately, this needs linking checkmail with libncursesw, + because plain libncurses chokes on multi-byte characters whose + parts do not look printable. This mode is now enabled by default, + tweak the Makefile if you do not have libncursesw. + 2007-06-25 Martin Mares * Non-ASCII characters encoded as per RFC 2047 are now deciphered diff --git a/Makefile b/Makefile index 11106e0..5b897b1 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,18 @@ +# Define if you want support for wide characters (needs libncursesw) +CONFIG_WIDE_CURSES=1 + #DEBUG=-ggdb CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline $(DEBUG) -std=gnu99 -DVERSION=$(VERSION) -DYEAR=$(YEAR) + +ifdef CONFIG_WIDE_CURSES +LDFLAGS=-lncursesw +CFLAGS+=-DCONFIG_WIDE_CURSES=1 +else LDFLAGS=-lncurses +endif -VERSION=1.0 -YEAR=2007 +VERSION=1.1 +YEAR=2008 all: cm diff --git a/README b/README index 7863091..3873dbc 100644 --- a/README +++ b/README @@ -2,7 +2,7 @@ Checkmail @VERSION@ - (c) 2005--2007 Martin Mares + (c) 2005--2008 Martin Mares ================================================================================ diff --git a/cm.c b/cm.c index 92141ef..a112a00 100644 --- a/cm.c +++ b/cm.c @@ -1,9 +1,11 @@ /* * Incoming Mail Checker * - * (c) 2005--2007 Martin Mares + * (c) 2005--2008 Martin Mares */ +#define _GNU_SOURCE + #include #include #include @@ -16,7 +18,12 @@ #include #include #include + +#ifdef CONFIG_WIDE_CURSES +#include +#else #include +#endif #include "util.h" #include "clists.h" @@ -611,7 +618,16 @@ redraw_line(int i) getyx(stdscr, yy, xx); int remains = COLS-1-xx; if (remains > 2) - printw("%-.*s", remains, b->snippet); + { +#ifdef CONFIG_WIDE_CURSES + size_t len = strlen(b->snippet)+1; + wchar_t snip[len]; + mbstowcs(snip, b->snippet, len); + addnwstr(snip, remains); +#else + printw("%-.*s", remains, b->snippet); +#endif + } } } } -- 2.39.2