-
Notifications
You must be signed in to change notification settings - Fork 717
Fixes #2182. Fix output of non-BMP Unicode characters in NetDriver. #2183
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
Conversation
@cpacejo I appreciate your contribution and for discovering of this issue. Before I make the changes in the NStack repo, the Terminal.Gui/Terminal.Gui/Core/ConsoleDriver.cs Lines 697 to 707 in b6dceb3
After I did the changes above and considering theses runes as single char the saga continues, see image bellow. Is the same problem that I was getting before, but now the right char is printed, thanks to you: If you want I can submitted a PR to your branch and maybe we could work together in this fix. Let me know, please. |
Somebody know how to write surrogate pairs with I already tried with the below but none print anything. Maybe it doesn't supported: Curses.addwstr (new string (spair));
Curses.addwstr ($"'{spair [0]}''{spair [1]}'");
Curses.addwstr ($"\'{spair [0]}'\'{spair [1]}'");
Curses.addwstr ($"\\'{spair [0]}'\\'{spair [1]}'"); |
Thanks for looking into this. I don't understand
Non-BMP characters aren't necessarily wide -- if you split them into two separate columns, I think that would make those two columns print as only one (narrow) character width on screen, making the line too short. Just like in the screen shot you show. I think it makes sense to store the full code point (even if it is non-BMP) in a single column, just like is already done. The code point just needs to be sent to the console driver in a way that the driver can understand. However on Linux in C,
displays "Aℝ𝔽!" I don't know how this translates to the Terminal.Gui wrapper for curses, which seems to use a (I never use the curses driver, as it just results in black and white squares on my screen, which I haven't had time to debug.) |
Yes you are right it's bad. I now see it's a hack for wide char. The problem is how to encode a surrogate pair in one column as you said, because in |
@cpacejo please confirm that the spacing in each char in the image must exist. If yes, then it must be used the superview color to avoid the black square and also be considered as wider, otherwise the line would be shorter and misaligned. |
No, there should be no spaces between those characters. As I mentioned in NStack bug #86, I believe this is occurring because |
Looking at WindowsDriver, it seems it would have to be rewritten somewhat to follow a similar model as NetDriver. Or modify |
So, the bug is in the public static Rune MakePrintable (Rune c)
{
if (c <= 0x1F || (c >= 0X7F && c <= 0x9F)) {
// ASCII (C0) control characters.
// C1 control characters (https://www.aivosto.com/articles/control-characters.html#c1)
return new Rune (c + 0x2400);
}
return c;
} |
With |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only fixes the |
So it does NOT completely close #2182? |
Yes it closes because its only mention the System.Console |
Fixes #2182. Breaks non-BMP Unicode characters into their surrogate pairs to work properly with System Console.
Widths for the test characters are wrong, but this is due to unrelated issue with NStack #86.
Pull Request checklist:
CTRL-K-D
to automatically reformat your files before committing.dotnet test
before commit///
style comments)