Search code examples
ccolorsiterm2widechar

C print wide chars in colors in iTerm2


I have a wide char wchar_t* string and I'd like to print it in color, with write(3)

something like this:

write(1, L"\x1b[31m", 5 * sizeof(wchar_t));
write(1, L"BLA", 3 * sizeof(wchar_t));
write(1, L"\x1b[0m", 5 * sizeof(wchar_t));

Prints [31mBLA[0m without colors.

And something like this:

write(1, "\x1b[31m", 5);
write(1, "BLA", 3);
write(1, "\x1b[0m", 5);

Correctly prints BLA in red.

Any idea how I can print wide char strings in color ?

EDIT: It seems to print correctly in Terminal.app but not in iTerm2 any idea why ?


Solution

  • Ok so this just isn't implemented yet in iTerm2, I've opened an issue here: iTerm2 issue 3460.

    A Milestone has been set to implement this I'll update the answer when it's done.