(Hopefully this threads correctly. I didn't actually register for the
mailing list the first time, but now it seems that it may be necessary.)

> I wouldn't say "compounding", but rather "not providing specialized
logic to work around the design limitations", etc.

Apologies, I think I have buried the lede. The problem is that, as far
as I can tell, ncurses is not even sending the expected data to the
terminal in the first place - but only for the "insert" calls, while the
"overwrite" calls work fine. It also happens without using the windowing
feature. A simpler example:

```
#include <locale.h>
#include <ncurses.h>

int main() {
    setlocale(LC_ALL, "");
    initscr();
    raw();
    mvaddwstr(0, 0, L"..\u2764\ufe0f...");
    mvins_wstr(1, 0, L"..\u2764\ufe0f...");
    refresh();
    getch();
    endwin();
}
```

This time, as well as running the program in a terminal, I checked
stdout directly:

```
$ echo q | ./a.out | xxd | cat
00000000: 1b5b 3f31 3034 3968 1b5b 3232 3b30 3b30  .[?1049h.[22;0;0
00000010: 741b 5b31 3b32 3472 1b28 421b 5b6d 1b5b  t.[1;24r.(B.[m.[
00000020: 346c 1b5b 3f37 681b 5b48 1b5b 324a 2e2e  4l.[?7h.[H.[2J..
00000030: e29d a4ef b88f 2e2e 2e0d 1b5b 3264 2e2e  ...........[2d..
00000040: e29d a420 2e2e 2e0d 711b 5b32 343b 3148  ... ....q.[24;1H
00000050: 1b5b 3f31 3034 396c 1b5b 3233 3b30 3b30  .[?1049l.[23;0;0
00000060: 740d 1b5b 3f31 6c1b 3e                   t..[?1l.>
```

(I've added periods to the output strings in order to left-align the
textual part of the output in the hex dump. The cat at the end is
suppressing colour added by xxd, and avoiding some display glitch that I
guess is from the interaction of the program's control codes with xxd.)

At 0x30 we see the bytes e29da4 (UTF-8 encoding of the heart character
itself) followed by efb88f (UTF-8 encoding of the variation selector
character). But at 0x40 (the text inserted by `mvins_wstr`) we see that
e29da4 is simply followed by 20 (i.e., an ASCII space).

I'm not expecting ncurses to do any special-casing in the output of the
heart emoji - especially since different terminals are already
attempting their own, mutually incompatible workarounds etc. But I do
expect that it should send the text that it was given. Or at least that
inserting and overwriting text do the same thing when the line is blank
to begin with.

This happens even at the beginning of a line, so it's not as if there's
some reason for `mvins_wstr` to truncate the text.

Reply via email to