php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49168 fgetcsv closure missbehaves when using '?' as closure
Submitted: 2009-08-05 10:33 UTC Modified: 2009-08-05 14:33 UTC
From: axel77 at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.10 OS: Ubuntu Linux
Private report: No CVE-ID: None
 [2009-08-05 10:33 UTC] axel77 at gmail dot com
Description:
------------
I was using '?' as closure, since this was the only character I fairly didn't even expect to encounter, without having to use any escaping.

It does not work. It will always add an additional trailing '?' on the data received.

Reproduce code:
---------------
--- reproduce.php ---
<html>
<style type="text/css">
table {border-collapse: collapse;}
td {border: 1px solid;}
</style>
<body><table><tbody>
<?php
  if (($handle = fopen('data', 'r')) === FALSE) {
      echo '<h1>ERROR: Unable to read data.</h1>';
      exit;
  }
  while (($data = fgetcsv($handle, 1000, ',', '?')) !== FALSE) {
      echo "<tr><td>$data[0]</td>";
      echo "<td>$data[1]</td>";
      echo "<td>$data[2]</td></tr>";
  }
  fclose($handle);
?>
</tbody></table></body></html>
-----------------
---  data --- 
abm, ?anjn an?, aaa
abm, anjn an, aaa
-----------------

Expected result:
----------------
abm | anjn an | aaa
abm | anjn an | aaa

Actual result:
--------------
abm | anjn an? | aaa
abm | anjn an  | aaa

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-05 10:43 UTC] derick@php.net
Are you sure you're using a single byte character for ??
 [2009-08-05 11:01 UTC] axel77 at gmail dot com
oh, no, sorry thats it, you can close this.

I expected it to be 1 character as it was in latin1, but at utf8 systems it turns out to be 2 characters.
 [2009-08-05 14:33 UTC] jani@php.net
As requested.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 02:01:29 2024 UTC