Skip to content
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

[Console] respect multi-byte characters when rendering vertical-style tables #54435

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Symfony/Component/Console/Helper/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,9 @@ public function render()
if ($headers && !$containsColspan) {
if (0 === $idx) {
$rows[] = [sprintf(
'<comment>%s</>: %s',
str_pad($headers[$i] ?? '', $maxHeaderLength, ' ', \STR_PAD_LEFT),
'<comment>%s%s</>: %s',
str_repeat(' ', $maxHeaderLength - Helper::width(Helper::removeDecoration($formatter, $headers[$i] ?? ''))),
$headers[$i] ?? '',
$part
)];
} else {
Expand Down
22 changes: 22 additions & 0 deletions src/Symfony/Component/Console/Tests/Helper/TableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,28 @@ public static function provideRenderVerticalTests(): \Traversable
$books,
];

yield 'With multibyte characters in some headers (the "í" in "Títle") and cells (the "í" in "Dívíne")' => [
<<<EOTXT
+-------------------------+
| ISBN: 99921-58-10-7 |
| Títle: Dívíne Comedy |
| Author: Dante Alighieri |
| Price: 9.95 |
+-------------------------+

EOTXT
,
['ISBN', 'Títle', 'Author', 'Price'],
[
[
'99921-58-10-7',
'Dívíne Comedy',
'Dante Alighieri',
'9.95',
],
],
];

yield 'With header for some' => [
<<<EOTXT
+------------------------------+
Expand Down