diff --git a/Formatter/OutputFormatter.php b/Formatter/OutputFormatter.php index eab86976d..c72728b27 100644 --- a/Formatter/OutputFormatter.php +++ b/Formatter/OutputFormatter.php @@ -275,6 +275,6 @@ private function addLineBreaks(string $text, int $width): string { $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8'; - return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); + return b($text)->toUnicodeString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); } } diff --git a/Tests/Formatter/OutputFormatterTest.php b/Tests/Formatter/OutputFormatterTest.php index b66b6abe4..489108bd5 100644 --- a/Tests/Formatter/OutputFormatterTest.php +++ b/Tests/Formatter/OutputFormatterTest.php @@ -373,6 +373,7 @@ public function testFormatAndWrap() $this->assertSame("foobar\e[37;41mbaz\e[39;49m\n\e[37;41mnewline\e[39;49m", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); $this->assertSame("foobar\e[37;41mbazne\e[39;49m\n\e[37;41mwline\e[39;49m", $formatter->formatAndWrap("foobarbazne\nwline", 11)); $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("foobarbaznew\nline", 11)); + $this->assertSame("\e[37;41m👩‍🌾\e[39;49m", $formatter->formatAndWrap('👩‍🌾', 1)); $formatter = new OutputFormatter(); @@ -392,6 +393,7 @@ public function testFormatAndWrap() $this->assertSame("foobarbaz\nnewline", $formatter->formatAndWrap("foobarbaz\nnewline", 11)); $this->assertSame("foobarbazne\nwline", $formatter->formatAndWrap("foobarbazne\nwline", 11)); $this->assertSame("foobarbazne\nw\nline", $formatter->formatAndWrap("foobarbaznew\nline", 11)); + $this->assertSame('👩‍🌾', $formatter->formatAndWrap('👩‍🌾', 1)); } }