-
-
Notifications
You must be signed in to change notification settings - Fork 500
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
Table column width miscalculated when value contains "accent" Unicode character #1599
Comments
This seems to be a bug in the wcwidth library. I will look into it. |
The whitespace "holes" in the Your For many scenarios, |
@elgonzo Thank you for the explanation! It indeed looks like an issue with specific terminals like cmd.exe rather than the library. I think there is nothing more to do on the side of Spectre.Console. As an additional test, I pasted a simple WorkaroundI'll paste the workaround I ended up with in case someone with a similar problem finds this thread.
ScreenshotCode// Variant 1
// (accent marks were the only characters problematic for Windows Terminal that I found)
Console.WriteLine("Strings without normalization:");
var table = new Table();
table.AddColumns("Field", "Value");
table.AddRow("Row 1", "ABCDEF");
table.AddRow("Row 2", "ąęúłśż");
table.AddRow("Row 3", "áéúíüñ");
table.AddRow("Row 4", "абвцде");
table.AddRow("Row 5", "а\u0301б\u0301в\u0301ц\u0301д\u0301е\u0301");
table.AddRow("Row 6", "a\u0301b\u0301c\u0301d\u0301e\u0301f\u0301");
table.AddRow("Row 7", "👍👎👌👏👋👊");
table.AddRow("Row 8", "你好嗎?我很");
table.AddRow("Row 9", "🇵🇱🇧🇷🇨🇦🇺🇸🇬🇧🇦🇺");
table.AddRow("Row 10", "أبجد ه");
AnsiConsole.Write(table);
// Variant 2
Console.WriteLine("Normalized with `string.Normalize(NormalizationForm.FormC)`:");
var table2 = new Table();
table2.AddColumns("Field", "Value");
table2.AddRow("Row 1", "ABCDEF".Normalize());
table2.AddRow("Row 5", "а\u0301б\u0301в\u0301ц\u0301д\u0301е\u0301".Normalize());
table2.AddRow("Row 6", "a\u0301b\u0301c\u0301d\u0301e\u0301f\u0301".Normalize());
AnsiConsole.Write(table2);
// Variant 3
Console.WriteLine("Normalized with `string.Normalize(NormalizationForm.FormC)`, remaining accent characters removed:");
string RemoveAccentMarks(string input) => string.Concat(input.Where(c => CharUnicodeInfo.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark));
var table3 = new Table();
table3.AddColumns("Field", "Value");
table3.AddRow("Row 1", "ABCDEF".Normalize());
table3.AddRow("Row 5", RemoveAccentMarks("а\u0301б\u0301в\u0301ц\u0301д\u0301е\u0301".Normalize()));
table3.AddRow("Row 6", RemoveAccentMarks("a\u0301b\u0301c\u0301d\u0301e\u0301f\u0301".Normalize()));
AnsiConsole.Write(table3); Thanks again for the support! |
Information
Describe the bug
When I display strings containing Unicode accent characters in the table context:
I tried troubleshooting (e.g. went through Best Practices -> Configuring the Windows Terminal For Unicode and Emoji Support) but with no difference. I am curious if this is a limitation of a Terminal, a bug, or if I am misusing the library and it can be fixed with a configuration change?
To Reproduce
Expected behavior
A table is rendered with the same column width in all rows.
Screenshots
Additional context
Thanks for your work and a great library! :)
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: