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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sat Dec 21 14:01:32 2024 UTC