php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80062 STDIN not support Chinese in CLI mode
Submitted: 2020-09-05 05:27 UTC Modified: 2020-09-05 09:33 UTC
From: tsxgt at 163 dot com Assigned: cmb (profile)
Status: Not a bug Package: Streams related
PHP Version: 7.4.10 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
20 + 27 = ?
Subscribe to this entry?

 
 [2020-09-05 05:27 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-05 06:51 UTC] tsxgt at 163 dot com
-Status: Open +Status: Closed
 [2020-09-05 06:51 UTC] tsxgt at 163 dot com
solved:

sapi_windows_cp_set(936);
 [2020-09-05 09:33 UTC] cmb@php.net
-Status: Closed +Status: Not a bug -Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 22:03:38 2021 UTC