1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 23:36:23 -05:00

Cater to wcwidth implementation difference (Cygwin: UTF-16, Linux: UTF-32).

This commit is contained in:
Renaud 2019-11-06 13:31:05 +08:00
parent b0362969a3
commit e71338b261
2 changed files with 7 additions and 0 deletions

3
main.c
View File

@ -65,6 +65,7 @@
* *
*/ */
#include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -140,6 +141,8 @@ int main(int argc, char **argv)
int errflag; /* C error processing? */ int errflag; /* C error processing? */
bname_t bname ; /* buffer name of file to read */ bname_t bname ; /* buffer name of file to read */
setlocale( LC_CTYPE, "") ; /* wide character support (UTF-32) */
#if PKCODE & BSD #if PKCODE & BSD
sleep(1); /* Time for window manager. */ sleep(1); /* Time for window manager. */
#endif #endif

4
utf8.c
View File

@ -11,8 +11,12 @@
* Display width of UTF-8 character * Display width of UTF-8 character
*/ */
unsigned utf8_width( unicode_t c) { unsigned utf8_width( unicode_t c) {
#ifdef CYGWIN
assert( sizeof( wchar_t) == 2) ; /* wcwidth only handle UTF-16 */ assert( sizeof( wchar_t) == 2) ; /* wcwidth only handle UTF-16 */
return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ; return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ;
#else
return (unsigned) wcwidth( (wchar_t) c) ;
#endif
} }
/* /*