Bug #72861 [Com]: fgetcsv get line error

From: Date: Fri, 14 Sep 2018 01:25:34 +0000
Subject: Bug #72861 [Com]: fgetcsv get line error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217040@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72861&edit=1 ID: 72861 Comment by: zhouliweb at sina dot com Reported by: zhouliweb at sina dot com Summary: fgetcsv get line error Status: Feedback Type: Bug Package: Filesystem function related Operating System: Win PHP Version: 7.0.9 Assigned To: cmb Block user comment: N Private report: N New Comment: I tried it just now(in windows with ;php7.0.9 & in centos with php7.1.12), the bug is already exist. orz Previous Comments: ------------------------------------------------------------------------ [2018-09-13 16:56:06] cmb@php.net I can't reproduce this. Is a.csv actually UTF-8 encoded? Are you using an UTF-8 locale (LC_CTYPE)? ------------------------------------------------------------------------ [2016-08-17 03:11:30] zhouliweb at sina dot com Description: ------------ While has japanese in the csv, fgetcsv get line error. More detail see the test script. Test script: --------------- $filename = "a.csv"; $file = fopen($filename, "r"); while(!feof($file) && $data = fgetcsv($file)) { echo json_encode($data) . "\n"; } fclose($file); a.csv is like this:(3 lines, the first line is unix LF, others is windows CR+LF) "a ましょう。" b Expected result: ---------------- ["a\n\u307e\u3057\u3087\u3046\u3002"] ["b"] Actual result: -------------- ["a\n\u307e\u3057\u3087\u3046\u3002\"\r\nb\r\n"] ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72861&edit=1

« previous php.bugs (#217040) next »