8000 [Console] Table counts wrong number of padding symbols in `renderCell()` method when cell contain unicode variant selector by vladimir-vv · Pull Request #60042 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Open
wants to merge 2 commits into
base: 6.4
Choose a base branch
from

Conversation

vladimir-vv
Copy link
@vladimir-vv vladimir-vv commented Mar 26, 2025
Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #60038
License MIT

When rendering a table in console and use emojis then width of columns could be wrong calculated.

@carsonbot
Copy link

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:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.3 branch.

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!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/
Could you update the PR base branch to target one of these branches instead? 6.4, 7.2, 7.3.

Cheers!

Carsonbot

@vladimir-vv vladimir-vv changed the base branch from 5.4 to 6.4 March 26, 2025 08:11
@fabpot
Copy link
Member
fabpot commented Mar 28, 2025

@vladimir-vv Can you add some unit tests that would cover this fix?

@OskarStark OskarStark changed the title issues/60038: Table counts wrong number of padding symbols in method … [Console] Table counts wrong number of padding symbols in method renderCell(..) when cell contain unicode variant selector Mar 28, 2025
@vladimir-vv
Copy link
Author
vladimir-vv commented Apr 1, 2025

@vladimir-vv Can you add some unit tests that would cover this fix?

Ok.
The testcase has been added.

@xabbuh
Copy link
Member
xabbuh commented Apr 29, 2025

@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");
Copy link
Member

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?

Copy link
Author

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

@OskarStark OskarStark changed the title [Console] Table counts wrong number of padding symbols in method renderCell(..) when cell contain unicode variant selector [Console] Table counts wrong number of padding symbols in renderCell() method when cell contain unicode variant selector May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0