-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Table counts wrong number of padding symbols in renderCell()
method when cell contain unicode variant selector
#60042
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
base: 6.4
Are you sure you want to change the base?
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Hey! Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/ Cheers! Carsonbot |
@vladimir-vv Can you add some unit tests that would cover this fix? |
Ok. |
@vladimir-vv Can you please rebase here to re-trigger the CI? |
…renderCell(..) when cell contain unicode variant selector.
…renderCell(..) when cell contain unicode variant selector. With testcase.
@@ -565,7 +565,7 @@ private function renderCell(array $row, int $column, string $cellFormat): string | |||
|
|||
// str_pad won't work properly with multi-byte strings, we need to fix the padding | |||
if (false !== $encoding = mb_detect_encoding($cell, null, true)) { | |||
$width += \strlen($cell) - mb_strwidth($cell, $encoding); | |||
$width += \strlen($cell) - mb_strwidth($cell, $encoding) + substr_count($cell, "\xef\xb8\x8f") + substr_count($cell, "\xef\xb8\x8e"); |
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.
What exactly does the unicode sequence \xef\xb8\x8e
refer to?
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.
These U+FE0F, U+FE0E selectors are used to display emoji with color or monochrome. As I can see usually the U+FE0E selector is skipped.
Example with snowflake:
U+2744 ❄ e2 9d 84
U+2744 ❄ e2 9d 84 ef b8 8e
U+2744 ❄️ e2 9d 84 ef b8 8f
renderCell()
method when cell contain unicode variant selector
When rendering a table in console and use emojis then width of columns could be wrong calculated.