Skip to content

Commit e847982

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: respect multi-byte characters when rendering vertical-style tables
2 parents 3f2ed0f + 3528d9e commit e847982

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/Symfony/Component/Console/Helper/Table.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,9 @@ public function render(): void
365365
if ($headers && !$containsColspan) {
366366
if (0 === $idx) {
367367
$rows[] = [sprintf(
368-
'<comment>%s</>: %s',
369-
str_pad($headers[$i] ?? '', $maxHeaderLength, ' ', \STR_PAD_LEFT),
368+
'<comment>%s%s</>: %s',
369+
str_repeat(' ', $maxHeaderLength - Helper::width(Helper::removeDecoration($formatter, $headers[$i] ?? ''))),
370+
$headers[$i] ?? '',
370371
$part
371372
)];
372373
} else {

src/Symfony/Component/Console/Tests/Helper/TableTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,28 @@ public static function provideRenderVerticalTests(): \Traversable
16491649
$books,
16501650
];
16511651

1652+
yield 'With multibyte characters in some headers (the "í" in "Títle") and cells (the "í" in "Dívíne")' => [
1653+
<<<EOTXT
1654+
+-------------------------+
1655+
| ISBN: 99921-58-10-7 |
1656+
| Títle: Dívíne Comedy |
1657+
| Author: Dante Alighieri |
1658+
| Price: 9.95 |
1659+
+-------------------------+
1660+
1661+
EOTXT
1662+
,
1663+
['ISBN', 'Títle', 'Author', 'Price'],
1664+
[
1665+
[
1666+
'99921-58-10-7',
1667+
'Dívíne Comedy',
1668+
'Dante Alighieri',
1669+
'9.95',
1670+
],
1671+
],
1672+
];
1673+
16521674
yield 'With header for some' => [
16531675
<<<EOTXT
16541676
+------------------------------+

0 commit comments

Comments
 (0)