php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34735 fgetcsv() lost with low or high value ascii chars
Submitted: 2005-10-04 17:43 UTC Modified: 2005-10-04 20:50 UTC
From: fcartegnie at nordnet dot fr Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.4.0 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fcartegnie at nordnet dot fr
New email:
PHP Version: OS:

 

 [2005-10-04 17:43 UTC] fcartegnie at nordnet dot fr
Description:
------------
fgetcsv does not handle extended ascii as separator or enclosure.

This code does not works with 0xF0 (chr 240), and/or with enclosures (0xF1, ...) while it works with common comma/quotes.

Tested also with setting up/changing locale.

Reproduce code:
---------------
$fp = fopen("test.csv", "w");
fwrite($fp, "A\xF0B\xF0C\xF0D");
fclose($fp);

$fp = fopen("test.csv", "r");
$data = fgetcsv ($fp, 8192, '\xF0', '');
fclose($fp);

print_r($data);

Expected result:
----------------
Array
(
    [0] => A
    [1] => B
    [2] => C
    [3] => D
)


Actual result:
--------------
Array
(
    [0] => A?B?C?D
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-04 20:50 UTC] tony2001@php.net
Change this line:
$data = fgetcsv ($fp, 8192, '\xF0', '');
to
$data = fgetcsv ($fp, 8192, "\xF0", '');
and you'll get what you expect.

Not a bug, as '\xF0' is string(4). 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 17 23:01:27 2024 UTC