php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42163 fgetcsv() gives different output with and without Unicode
Submitted: 2007-08-01 08:43 UTC Modified: 2008-02-10 02:15 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: *Unicode Issues
PHP Version: 6CVS-2007-08-01 (snap) OS: Linux, Win32-xp
Private report: No CVE-ID: None
 [2007-08-01 08:43 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
fgetcsv() outputs different results with and without Unicode on Windows and Linux.

Reproduce code:
---------------
--TEST--
Test fgetcsv()
--FILE--
<?php

$filename = dirname(__FILE__) . '/fgetcsv.tmp';


// create the file and add the content with has csv fields
$file_handle = fopen($filename, "w+t" );

$delimiter = '-';
$enclosure = '-';
$csv_field = '-water---fruit---air-';


@fwrite($file_handle, $csv_field );

// rewind the file pointer to bof
rewind($file_handle);

// use the right delimiter and enclosure with max length
var_dump( fgetcsv($file_handle, 1024, $delimiter, $enclosure) );

// close the file
fclose($file_handle);
//delete file
unlink($filename);

echo "Done\n";
?>
--EXPECT--

Expected result:
----------------
array(2) {
  [0]=>
  string(11) "water-fruit"
  [1]=>
  string(3) "air"
}
Done

Actual result:
--------------
array(1) {
  [0]=>
  unicode(12) "wat^@^@^@fruitt"
}
Done

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-10 02:15 UTC] felipe@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 21:01:29 2024 UTC