[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: something wrong with wchar_t printing?
From: |
Thomas Dickey |
Subject: |
Re: something wrong with wchar_t printing? |
Date: |
Tue, 1 May 2018 21:26:25 -0400 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Tue, May 01, 2018 at 06:19:39PM +0200, folkert wrote:
> Hi,
>
> I wrote a question on stackoverflow regarding printing of std::wstring
> using ncurses
> (https://stackoverflow.com/questions/50118848/utf-8-stdwstring-ncurses ).
> I'm starting to believe the problem is in waddwstr.
>
> If I have a utf-8 string in "temp", then convert that to std::wstring
> using
> std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
> std::wstring wstr = converter.from_bytes(temp);
> then
> waddwstr(win, wstr.c_str());
> prints a space for CERTAIN special characters. An U+00E4 prints fine but an
> U+1F5E0 prints as a space.
> If I print them in utf-8 format using wprintw, they come out allright.
offhand, this seems to be what you're testing (but a trace shows
me the same UTF-8 for the addwstr):
#include <ncurses.h>
#include <locale.h>
int
main(void)
{
static wchar_t case1[2] = {0x1f5e0, 0};
static char case2[] = "\360\237\227\240\0";
setlocale(LC_ALL, "");
initscr();
cbreak();
noecho();
addwstr(case1);
printw("%s", case2);
getch();
endwin();
return 0;
}
--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: Digital signature