Bug #72330 [Csd]: str_getcsv() splits fields incorrectly if escape char flollowed by UTF chars

From: Date: Sun, 17 Jul 2016 11:08:52 +0000
Subject: Bug #72330 [Csd]: str_getcsv() splits fields incorrectly if escape char flollowed by UTF chars
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202371@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72330&edit=1 ID: 72330 User updated by: cronfy at gmail dot com Reported by: cronfy at gmail dot com Summary: str_getcsv() splits fields incorrectly if escape char flollowed by UTF chars Status: Closed Type: Bug Package: Strings related Operating System: Linux Mint 17.1 Rebecca PHP Version: Irrelevant Assigned To: cmb Block user comment: N Private report: N New Comment: I can't change this bug status to Reopened, because I do not have enough privileges. Previous Comments: ------------------------------------------------------------------------ [2016-07-17 11:07:50] cronfy at gmail dot com Yes, it it locale dependent. If I prepend script with 'setlocale(LC_ALL, "C")', everything works correctly. But if I don't (my default locale is ru_RU.UTF-8) or if I explicitly use 'setlocale(LC_ALL, "ru_RU")', result is incorrect. I can't demonstrate it at 3v4l.org as it does not support required locales. ------------------------------------------------------------------------ [2016-06-26 04:22:26] php-bugs at lists dot php dot net No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. ------------------------------------------------------------------------ [2016-06-14 13:21:21] cmb@php.net I can't reproduce this behavior, see <https://3v4l.org/QZJSC>. Maybe it's locale dependend? ------------------------------------------------------------------------ [2016-06-03 16:00:42] cronfy at gmail dot com Description: ------------ When escape character set for str_getcsv() is followed by some UTF characters, string is parsed incorrectly. I tested it on php 5.4, 5.5, 5.6 and 7.0 - behavior is the same. Test script: --------------- $utf_1 = chr(0xD1) . chr(0x81); // U+0440; $utf_2 = chr(0xD8) . chr(0x80); // U+0600 $string = '"first #' . $utf_1 . $utf_2 . '";"second one"'; $d = str_getcsv($string, ';', '"', "#"); print_r($d); Expected result: ---------------- Array ( [0] => first #с؀ [1] => second one ) Actual result: -------------- Array ( [0] => first #с؀";second one" ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72330&edit=1

« previous php.bugs (#202371) next »