[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: |
LIU Hao |
Subject: |
Re: UTF-8 multi-byte characters are not displayed properly on Windows consoles |
Date: |
Fri, 13 Jan 2023 00:59:15 +0800 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 |
Thank you, Thomas.
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, "");
Yeah I thought ncurses just write a byte string to the console without being aware of its encoding;
apparently I was wrong.
For the record:
`setlocale(LC_ALL, "")` does NOT set a UTF-8 locale on Windows. For example,
on my system it
sets up the conventional DBCS locale, and returns `Chinese
(Simplified)_China.936`, even when
UTF-8 is in effect. It is possible, however, to request a UTF-8 locale with
`setlocale(LC_ALL,
".65001")` with UCRT. This has the desired effect, and now UTF-8 strings
work as expected.
There is another issue: When nano is told to read text from standard input, it loses response as
soon as input is over, like this:
```
> echo | src\nano.exe -
Reading data from keyboard; type ^D or ^D^D to finish.
Too many errors from stdin
Buffer written to nano.11200.save
```
The cause of this issue is described in the attached patch. Please take a look if you happen to have
some time.
Thanks for your help!
--
Best regards,
LIU Hao
ncurses-6.4_console_handles.patch
Description: Text document
OpenPGP_signature
Description: OpenPGP digital signature