From e71338b261c7924153bcca235e8fe7d44d3a7d15 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Wed, 6 Nov 2019 13:31:05 +0800 Subject: [PATCH] Cater to wcwidth implementation difference (Cygwin: UTF-16, Linux: UTF-32). --- main.c | 3 +++ utf8.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/main.c b/main.c index 5f0a9eb..c409d0a 100644 --- a/main.c +++ b/main.c @@ -65,6 +65,7 @@ * */ +#include #include #include #include @@ -140,6 +141,8 @@ int main(int argc, char **argv) int errflag; /* C error processing? */ bname_t bname ; /* buffer name of file to read */ + setlocale( LC_CTYPE, "") ; /* wide character support (UTF-32) */ + #if PKCODE & BSD sleep(1); /* Time for window manager. */ #endif diff --git a/utf8.c b/utf8.c index 181f6ac..f06b7ac 100644 --- a/utf8.c +++ b/utf8.c @@ -11,8 +11,12 @@ * Display width of UTF-8 character */ unsigned utf8_width( unicode_t c) { +#ifdef CYGWIN assert( sizeof( wchar_t) == 2) ; /* wcwidth only handle UTF-16 */ return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ; +#else + return (unsigned) wcwidth( (wchar_t) c) ; +#endif } /*