Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcfe2fcc

Browse files
bug#61319 [Console] [Table] Don't split grapheme clusters (schlndh)
This PR was merged into the 6.4 branch.Discussion----------[Console] [Table] Don't split grapheme clusters| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues || License | MITThis change prevents splitting of grapheme clusters due to wrapping in Table. The emoji consists of multiple code points, so `CodePointString` chunked it into multiple pieces and wordrap then split them into separate lines. E.g.:```--- Expected+++ Actual@@ @@-'👩‍🌾'+'👩+‍+🌾'```Commits-------c258c19 [Console][Table] Don't split grapheme clusters
2 parentsad80125 +c258c19 commitcfe2fcc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

‎src/Symfony/Component/Console/Formatter/OutputFormatter.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,6 @@ private function addLineBreaks(string $text, int $width): string
285285
{
286286
$encoding =mb_detect_encoding($text,null,true) ?:'UTF-8';
287287

288-
returnb($text)->toCodePointString($encoding)->wordwrap($width,"\n",true)->toByteString($encoding);
288+
returnb($text)->toUnicodeString($encoding)->wordwrap($width,"\n",true)->toByteString($encoding);
289289
}
290290
}

‎src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ public function testFormatAndWrap()
373373
$this->assertSame("foobar\e[37;41mbaz\e[39;49m\n\e[37;41mnewline\e[39;49m",$formatter->formatAndWrap("foobar<error>baz\nnewline</error>",11));
374374
$this->assertSame("foobar\e[37;41mbazne\e[39;49m\n\e[37;41mwline\e[39;49m",$formatter->formatAndWrap("foobar<error>bazne\nwline</error>",11));
375375
$this->assertSame("foobar\e[37;41mbazne\e[39;49m\n\e[37;41mw\e[39;49m\n\e[37;41mline\e[39;49m",$formatter->formatAndWrap("foobar<error>baznew\nline</error>",11));
376+
$this->assertSame("\e[37;41m👩‍🌾\e[39;49m",$formatter->formatAndWrap('<error>👩‍🌾</error>',1));
376377

377378
$formatter =newOutputFormatter();
378379

@@ -392,6 +393,7 @@ public function testFormatAndWrap()
392393
$this->assertSame("foobarbaz\nnewline",$formatter->formatAndWrap("foobar<error>baz\nnewline</error>",11));
393394
$this->assertSame("foobarbazne\nwline",$formatter->formatAndWrap("foobar<error>bazne\nwline</error>",11));
394395
$this->assertSame("foobarbazne\nw\nline",$formatter->formatAndWrap("foobar<error>baznew\nline</error>",11));
396+
$this->assertSame('👩‍🌾',$formatter->formatAndWrap('👩‍🌾',1));
395397
}
396398
}
397399

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp