php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: giacobbe_85 at tiscali dot it
New email:
PHP Version: OS:

 

 [2018-09-17 19:22 UTC] giacobbe_85 at tiscali dot it
Description:
------------
*** 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:
---------------
<?PHP

// 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):

ò
950d0a
à
85

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

ò
000d0a
à
00

Patches

Pull Requests

History

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

As of PHP 7.1.0 you need to set the internal_encoding properly
for this to work.  For details see
<http://php.net/manual/en/migration71.windows-support.php#migration71.windows-support.long-and-utf8-path>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 07 03:01:28 2024 UTC