Bug #76897 [Opn->Nab]: PHP CLI accepts only basic ASCII characters on STDIN

From: Date: Tue, 18 Sep 2018 15:13:27 +0000
Subject: Bug #76897 [Opn->Nab]: PHP CLI accepts only basic ASCII characters on STDIN
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217120@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76897&edit=1 ID: 76897 Updated by: cmb@php.net Reported by: giacobbe_85 at tiscali dot it Summary: PHP CLI accepts only basic ASCII characters on STDIN -Status: Open +Status: Not a bug Type: Bug Package: *Unicode Issues Operating System: Windows PHP Version: 7.1.22 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: 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>. Previous Comments: ------------------------------------------------------------------------ [2018-09-17 19:22:21] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76897&edit=1

« previous php.bugs (#217120) next »