|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76897 PHP CLI accepts only basic ASCII characters on STDIN
Submitted: 2018-09-17 19:22 UTC Modified: 2018-09-18 15:13 UTC
From: giacobbe_85 at tiscali dot it Assigned: cmb (profile)
Status: Not a bug Package: *Unicode Issues
PHP Version: 7.1.22 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: giacobbe_85 at tiscali dot it
New email:
PHP Version: OS:


 [2018-09-17 19:22 UTC] giacobbe_85 at tiscali dot it
*** Test conditions: 
Windows 10 Home 64 bit
Windows 7 Pro 64 bit
Command line charsets: cp850, cp1252, cp65001

*** PHP Version tested:
All PHP 7.2.10 versions (x64 / x86, thread safe / non thread safe)
All PHP 7.1.22 versions (x64 / x86, thread safe / non thread safe)

*** Symptoms
When executed from command line, PHP interpreter only accepts from STDIN characters with decimal code smaller than 127 of the current charset. All characters with a bigger code will be read as 0. In other words, no special character can be inputed on the command line, except the basic ASCII ones. If a special character (accented, umlauts, etc) is typed, it will be NULL.

The problem is not present if older versions of PHP are used, like PHP 7.0.32 Win32 VC14 x64 or PHP 5.x

Test script:

// Read string contains end line chars
$s = fgets(STDIN);
echo bin2hex($s);

// Read string doesn't contain end line chars
$s = stream_get_line(STDIN, 999999, PHP_EOL);
echo bin2hex($s);


Expected result:
If, for example, the user inputs the "ò" and "à" characters, the CLI output should be (assume cp850 as charset):


Actual result:
If, for example, the user inputs the "ò" and "à" characters, the CLI output is:



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-18 15:13 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2018-09-18 15:13 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

As of PHP 7.1.0 you need to set the internal_encoding properly
for this to work.  For details see
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 23 21:01:30 2024 UTC