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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tsxgt at 163 dot com
New email:
PHP Version: OS:

 

 [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: Tue Nov 30 10:03:35 2021 UTC