Bug #80062 [Csd->Nab]: STDIN not support Chinese in CLI mode

From: Date: Sat, 05 Sep 2020 09:33:09 +0000
Subject: Bug #80062 [Csd->Nab]: STDIN not support Chinese in CLI mode
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228894@lists.php.net to get a copy of this message
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)

« previous php.bugs (#228894) next »