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

[Console][Table] Invalid "UTF-8" string caused by text warping #58286

Open
@lcharette

Description

@lcharette

Symfony version(s) affected

6.4

Description

When using the Consoletable helper, the following exception is sometimes thrown :Invalid "UTF-8" string.. I've found the cause to be the following line, which may split an UTF-8 character badly when the cell text is wrapped on multiple line.

https://github.com/symfony/console/blob/3e36da1448dd7bd64e623135da852858ec6fb72e/Formatter/OutputFormatter.php#L172

applyCurrentStyle will indeed receive an Invalid "UTF-8" string because of the result ofsubstr:

Screenshot

Explanation :https://www.php.net/manual/en/function.substr.php#90581

How to reproduce

Code :

#!/usr/bin/env php<?php// First, run "composer require symfony/console"require__DIR__.'/vendor/autoload.php';useSymfony\Component\Console\Application;useSymfony\Component\Console\Command\Command;useSymfony\Component\Console\Helper\Table;useSymfony\Component\Console\Input\InputInterface;useSymfony\Component\Console\Output\OutputInterface;$application =newApplication();// ... register commands$application->register('debug')    ->setCode(function (InputInterface$input,OutputInterface$output):int {$table =newTable($output);$table->setHeaders(['Message']);$table->setColumnMaxWidth(0,50);$table->addRow(["Usuário <strong>{{user_name}}</strong> não é válido."        ]);$table->render();return Command::SUCCESS;    });$application->run();

Run :

php test.php debug

Result should be :

In ByteString.php line 444:                             Invalid "UTF-8" string.                             debug

Possible Solution

Replacingsubstr withmb_substr onthis line will solve the issue. However it might be prudent to check ifmb_substr should be used elsewhere.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp