You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #61242 [Console] [Table] Fix invalid UTF-8 due to text wrapping (schlndh)
This PR was merged into the 6.4 branch.
Discussion
----------
[Console] [Table] Fix invalid UTF-8 due to text wrapping
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#58286
| License | MIT
I changed the `OutputFormatter` to use string methods from `Helper` to avoid splitting multi-byte UTF-8 characters and causing the "Invalid UTF-8" exception as a result. Unfortunately, it turns out that `Helper::length` and `Helper::substr` are not mutually compatible for UTF-8, because `length` returns the length in graphemes, while `substr` worked with characters. I decided to fix that, which is technically a BC break (hopefully not too severe). I considered making a private fixed copy of the method, but that just seemed weird.
Commits
-------
218ca62 [Console][Table] Fix invalid UTF-8 due to text wrapping
$this->assertSame("Usuário <strong>{{user_name}}</strong> não é válid\no.", $formatter->formatAndWrap('Usuário <strong>{{user_name}}</strong> não é válido.', 50));
368
370
369
371
$formatter = newOutputFormatter();
370
372
@@ -376,6 +378,8 @@ public function testFormatAndWrap()
$this->assertSame("Usuário <strong>{{user_name}}</strong> não é válid\no.", $formatter->formatAndWrap('Usuário <strong>{{user_name}}</strong> não é válido.', 50));
0 commit comments