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
 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC