Skip to content

Commit

Permalink
Improve UTF-8 display under NetBSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
rfivet committed Jun 20, 2020
1 parent 4847d8c commit 2f5d28a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ 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) */
setlocale( LC_CTYPE, "en_GB.UTF-8") ; /* wide character support (UTF-32) */

#if PKCODE & BSD
sleep(1); /* Time for window manager. */
Expand Down
5 changes: 3 additions & 2 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ unsigned utf8_width( unicode_t c) {
assert( sizeof( wchar_t) == 2) ; /* wcwidth only handles UTF-16 */
return (c < 0x10000) ? (unsigned) wcwidth( (wchar_t) c) : 2 ;
#elif BSD
assert( sizeof( wchar_t) == 4) ; /* wcwidth should handle UTF-32 */
return 1 ;
// assert( sizeof( wchar_t) == 4) ; /* wcwidth should handle UTF-32 */
int ret = wcwidth( (wchar_t) c) ;
return (ret < 0) ? 1 : (unsigned) ret ;
#else
return (unsigned) wcwidth( (wchar_t) c) ;
#endif
Expand Down

0 comments on commit 2f5d28a

Please sign in to comment.