Bug #76897 [NEW]: PHP CLI accepts only basic ASCII characters on STDIN

From: Date: Mon, 17 Sep 2018 19:22:21 +0000
Subject: Bug #76897 [NEW]: PHP CLI accepts only basic ASCII characters on STDIN
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217102@lists.php.net to get a copy of this message
From: giacobbe_85 at tiscali dot it Operating system: Windows PHP version: 7.1.22 Package: *Unicode Issues Bug Type: Bug Bug description:PHP CLI accepts only basic ASCII characters on STDIN 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 bug report at https://bugs.php.net/bug.php?id=76897&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76897&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76897&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76897&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=76897&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=76897&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=76897&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=76897&r=needscript Try newer version: https://bugs.php.net/fix.php?id=76897&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=76897&r=support Expected behavior: https://bugs.php.net/fix.php?id=76897&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=76897&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=76897&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=76897&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76897&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=76897&r=dst IIS Stability: https://bugs.php.net/fix.php?id=76897&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=76897&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=76897&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=76897&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=76897&r=mysqlcfg

« previous php.bugs (#217102) next »