bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: UTF-8 multi-byte characters are not displayed properly on Windows co


From: Thomas Dickey
Subject: re: UTF-8 multi-byte characters are not displayed properly on Windows consoles
Date: Thu, 12 Jan 2023 04:06:05 -0500
User-agent: Mutt/1.10.1 (2018-07-13)

> Date: Thu, 12 Jan 2023 15:30:20 +0800
> From: LIU Hao <lh_mouse@126.com>
> To: bug-ncurses@gnu.org
> Subject: UTF-8 multi-byte characters are not displayed properly on Windows
>  consoles
> 
> Hello folks,
> 
> I'm mingw-w64 developer and MSYS2 contributor, and I maintain a GNU nano
> port to Windows [1]. First of all, thank you for the great work!
> 
> Since Windows 10, the Windows console has gained UTF-8 support, which
> however has to be enabled explicitly in system control panel. After UTF-8
> support has been enabled and the UTF-8 code page has been set up with the
> `chcp 65001` command, all standard C ctype functions can work on UTF-8
> strings.
> 
> However, when GNU nano attempts to display a UTF-8 string, it is taken
> bytewise and becomes gibberish. I have created this testcase, for example:
> 
>    ```
>    #include <ncursesw/ncurses.h>
     #include <locale.h>
> 
>    int
>    main(void)
>      {

This doesn't set the locale (which nano normally does).
Without setting a valid locale which uses UTF-8 encoding,
ncurses won't do much of any use.
         setlocale(LC_ALL, "");

>        initscr();
>        addstr("»·");  // hex: C2 BB C2 B7
>        refresh();
>        getch();
>      }
>    ```
> 
> The commented string literal contains two characters as four bytes. On Linux
> it is displayed properly, but on a Windows UTF-8 console I get `»·`. How
> should I fix it?
> 
> 
> [1] https://github.com/lhmouse/nano-win
> 
> 
> -- 
> Best regards,
> LIU Hao

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]