Skip to content

Commit 6ae4ac9

Browse files
bug symfony#49987 [Console] Restoring the ability to output unicode text to the Win10 console (aleksandr-shevchenko)
This PR was submitted for the 6.3 branch but it was merged into the 5.4 branch instead. Discussion ---------- [Console] Restoring the ability to output unicode text to the Win10 console | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Restoring the ability to output unicode text to the Win10 console after corrupting the console on line 224 in symfony/console/Terminal.php ``` require_once __DIR__ . '/../vendor/autoload.php'; use App\Commands\ClearcacheCommand; use Symfony\Component\Console\Application; echo "abc йфяЙФЯёЁ üÜiİöÖğĞıIəƏçÇşŞ" . PHP_EOL; $app = new Application(); $app->setName("abc йфяЙФЯёЁ üÜiİöÖğĞıIəƏçÇşŞ"); $app->setVersion("0.0.001"); $app->run(); ``` before <img width="691" alt="ss_2023_04_10__13_58_30" src="https://user-images.githubusercontent.com/25248634/230881661-6506c435-f57f-4cd6-924f-5e6bb437f2b4.png"> after <img width="440" alt="ss_2023_04_10__14_00_31" src="https://user-images.githubusercontent.com/25248634/230881671-9be5dc82-87f2-4eae-b24a-54e83b77f3b7.png"> Commits ------- 91a364c [Console] Restoring the ability to output unicode text to the Win10 console
2 parents 026286b + 91a364c commit 6ae4ac9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/Symfony/Component/Console/Terminal.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ private static function readFromProcess(string $command): ?string
157157
2 => ['pipe', 'w'],
158158
];
159159

160+
$cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
161+
160162
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
161163
if (!\is_resource($process)) {
162164
return null;
@@ -167,6 +169,10 @@ private static function readFromProcess(string $command): ?string
167169
fclose($pipes[2]);
168170
proc_close($process);
169171

172+
if ($cp) {
173+
sapi_windows_cp_set($cp);
174+
}
175+
170176
return $info;
171177
}
172178
}

0 commit comments

Comments
 (0)