Bug #80062 [Csd->Nab]: STDIN not support Chinese in CLI mode
Edit report at https://bugs.php.net/bug.php?id=80062&edit=1
ID: 80062
Updated by: cmb@php.net
Reported by: tsxgt at 163 dot com
Summary: STDIN not support Chinese in CLI mode
-Status: Closed
+Status: Not a bug
Type: Bug
Package: Streams related
Operating System: Windows
PHP Version: 7.4.10
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Indeed. See also <https://www.php.net/manual/en/migration71.windows-support.php#migration71.windows-support.long-and-utf8-path>.
Previous Comments:
------------------------------------------------------------------------
[2020-09-05 06:51:50] tsxgt at 163 dot com
solved:
sapi_windows_cp_set(936);
------------------------------------------------------------------------
[2020-09-05 05:27:54] tsxgt at 163 dot com
Description:
------------
Windows system, run a php file with chinese character in PHP CLI mode, it return s unexpected value
PHP 5.6.40 is ok
PHP 7.0.33 is ok
PHP >= 7.1.33 is bad
Test script:
---------------
<?php
while (1) {
$s = fgets(STDIN);
echo var_dump($s);
echo bin2hex($s);
echo "\r\n";
}
Expected result:
----------------
aaa
string(5) "aaa
"
6161610d0a
ä½ å¥½
string(6) "ä½ å¥½
"
c4e3bac30d0a
Actual result:
--------------
aaa
string(5) "aaa
"
6161610d0a
ä½ å¥½
string(4) "\000\000
"
00000d0a
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80062&edit=1
Thread (3 messages)