#38929 [Opn->Bgs]: fputcsv() fgetcsv() inconsistency even number backslashes then enclosure char

From: Date: Mon, 25 Sep 2006 12:24:19 +0000
Subject: #38929 [Opn->Bgs]: fputcsv() fgetcsv() inconsistency even number backslashes then enclosure char
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102637@lists.php.net to get a copy of this message
ID: 38929 Updated by: tony2001@php.net Reported By: mike at opendns dot com -Status: Open +Status: Bogus Bug Type: *Directory/Filesystem functions Operating System: Linux, debian sarge PHP Version: 5.1.6 New Comment: The same problem as #38918. Previous Comments: ------------------------------------------------------------------------ [2006-09-22 20:05:05] mike at opendns dot com Description: ------------ If you write a string to file with fputcsv that contains an even number of backslashes follwed by the enclosure character, you don't get your enclosure character back when you read it back in with fgetcsv(). Then you'll get an extra trailing enclosure character at the end of your string. Reproduce code: --------------- $tmp_file = '/tmp/csv_f_up.tmp'; $data_to_write = array('string contains even number of backslashes \\\\" followed by enclosure char'); echo "data_to_write:\n"; var_dump($data_to_write); $h_w = fopen($tmp_file, 'w'); fputcsv($h_w, $data_to_write); fclose($h_w); $h_r = fopen($tmp_file, 'r'); $data_read_in = fgetcsv($h_r); fclose($h_r); echo "data_read_in:\n"; var_dump($data_read_in); Expected result: ---------------- data_to_write: array(1) { [0]=> string(73) "string contains even number of backslashes \\" followed by enclosure char" } data_read_in: array(1) { [0]=> string(73) "string contains even number of backslashes \\" followed by enclosure char" } Actual result: -------------- data_to_write: array(1) { [0]=> string(73) "string contains even number of backslashes \\" followed by enclosure char" } data_read_in: array(1) { [0]=> string(73) "string contains even number of backslashes \\ followed by enclosure char"" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38929&edit=1

« previous php.bugs (#102637) next »