1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-20 16:22:38 -05:00

Improve UTF-8 display under NetBSD.

This commit is contained in:
Renaud 2020-06-20 14:25:53 +08:00
parent 4847d8c589
commit 2f5d28a864
2 changed files with 4 additions and 3 deletions

2
main.c
View File

@ -141,7 +141,7 @@ 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) */ setlocale( LC_CTYPE, "en_GB.UTF-8") ; /* wide character support (UTF-32) */
#if PKCODE & BSD #if PKCODE & BSD
sleep(1); /* Time for window manager. */ sleep(1); /* Time for window manager. */

5
utf8.c
View File

@ -15,8 +15,9 @@ unsigned utf8_width( unicode_t c) {
assert( sizeof( wchar_t) == 2) ; /* wcwidth only handles UTF-16 */ assert( sizeof( wchar_t) == 2) ; /* wcwidth only handles UTF-16 */
return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ; return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ;
#elif BSD #elif BSD
assert( sizeof( wchar_t) == 4) ; /* wcwidth should handle UTF-32 */ // assert( sizeof( wchar_t) == 4) ; /* wcwidth should handle UTF-32 */
return 1 ; int ret = wcwidth( (wchar_t) c) ;
return (ret < 0) ? 1 : (unsigned) ret ;
#else #else
return (unsigned) wcwidth( (wchar_t) c) ; return (unsigned) wcwidth( (wchar_t) c) ;
#endif #endif