-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-byte characters not supported? #84
Comments
What OS and terminal is this on? |
Hey, it's on Void Linux, Fish shell. |
What is the terminal app, font and locale setting, LANG= thanks |
Alacritty, LiterationMono Nerd Font Mono from https://www.nerdfonts.com/, en_US.UTF-8 |
Hi! I am experiencing the same issue here, with Ubuntu 22.04, gnome-terminal, LANG= $ { ./torture | head -75; sleep 1m; } | ./ttyplot -c '┆' displays this: The displayed image is the same whatever non-ASCII character I pass to Looking at the source code, it is clear that non-ASCII characters cannot possibly work. The option case 'c':
plotchar=optarg[0];
break; Here, |
@edgar-bonet nice analysis! 👍 |
Yes, excellent find! Sadly a 100% correct solution will require something like iconv and a library dependency. A solution for the maybe most common case UTF-8 would require calling |
@MIvanchev: I think we could use Note that #include <stdio.h>
#include <stdlib.h>
#include <locale.h>
int main(int argc, char *argv[])
{
if (argc != 2) {
fprintf(stderr, "Usage: %s character\n", argv[0]);
return EXIT_FAILURE;
}
setlocale(LC_ALL, "");
wchar_t c;
if (mbtowc(&c, argv[1], MB_CUR_MAX) < 1) {
fprintf(stderr, "Could not convert %s\n", argv[1]);
return EXIT_FAILURE;
}
printf("U+%04X\n", c);
return EXIT_SUCCESS;
} It successfully converts non-ASCII characters: $ ./read-wchar ┆
U+2506 |
Yeah @edgar-bonet that sounds like the way to go! Let's draw straws to see who has to write the patch. I'll go first. This is my straw: ~=====~ |
@MIvanchev: Here is mine |
You're too fast! I just had another idea that doesn't use wide strings and thus no change in dependencies. We could use
|
How would you draw vertical lines with this ttyplot@master uses Maybe replacing |
Let me see if I remember how programming works... |
Scrape my idea, I tested extensively over the weekend and it doesn't really work, ncurses doesn't seem to support multi-byte chars through char. |
@MIvanchev: In the mean time, multi-byte characters work file on the |
Yeah, I know, they have worked for a long time thanks to your effort :D I was just curious whether ncursesw is really necessary but it seems it really is ¯\(ツ)/¯ |
Closing as fixed by #99… |
I'm using ttyplot and I LOVE it, but whenever I set -c to one of https://en.wikipedia.org/wiki/Block_Elements, the display becomes kaleidoscopic. So I have the suspicion that multi-byte characters are not properly supported?
The text was updated successfully, but these errors were encountered: