8000 [Console] Fix Windows code page support · symfony/symfony@48ffffc · GitHub
[go: up one dir, main page]

Skip to content

Commit 48ffffc

Browse files
committed
[Console] Fix Windows code page support
1 parent 649d115 commit 48ffffc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ private function readInput($inputStream, Question $question)
512512
$cp = $this->setIOCodepage();
513513
$ret = fgets($inputStream, 4096);
514514

515-
return false !== $ret ? $this->resetIOCodepage($cp, $ret) : false;
515+
return $this->resetIOCodepage($cp, $ret);
516516
}
517517

518518
$multiLineStreamReader = $this->cloneInputStream($inputStream);
@@ -552,11 +552,18 @@ private function setIOCodepage(): int
552552
/**
553553
* Set console I/O to the specified code page and convert the user input.
554554
*/
555-
private function resetIOCodepage(int $cp, string $input): string
555+
private function resetIOCodepage(int $cp, $input)
556556
{
557-
if (\function_exists('sapi_windows_cp_set') && 0 < $cp) {
557+
if (0 === $cp) {
558+
return $input;
559+
}
560+
561+
if (\function_exists('sapi_windows_cp_set')) {
558562
sapi_windows_cp_set($cp);
559-
$input = sapi_windows_cp_conv(sapi_windows_cp_get('oem'), $cp, $input);
563+
564+
if (!empty($input)) {
565+
$input = sapi_windows_cp_conv(sapi_windows_cp_get('oem'), $cp, $input);
566+
}
560567
}
561568

562569
return $input;

0 commit comments

Comments
 (0)
0