#49168 [Opn->Bgs]: fgetcsv closure missbehaves when using '§' as closure
| From: | jani@php.net | Date: | Wed, 05 Aug 2009 14:33:25 +0000 |
| Subject: | #49168 [Opn->Bgs]: fgetcsv closure missbehaves when using '§' as closure | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140686@lists.php.net to get a copy of this message | ||
ID: 49168
Updated by: jani@php.net
Reported By: axel77 at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Filter related
Operating System: Ubuntu Linux
PHP Version: 5.2.10
New Comment:
As requested.
Previous Comments:
------------------------------------------------------------------------
[2009-08-05 11:01:56] 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 10:43:27] derick@php.net
Are you sure you're using a single byte character for §?
------------------------------------------------------------------------
[2009-08-05 10:33:56] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49168&edit=1