|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30335 fgetcsv + foreign characters
Submitted: 2004-10-06 10:29 UTC Modified: 2004-10-16 01:00 UTC
Avg. Score:4.6 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:1 (12.5%)
Same OS:5 (62.5%)
From: gruszczol1 at poczta dot onet dot pl Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.0.2 OS: linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-10-06 10:29 UTC] gruszczol1 at poczta dot onet dot pl
fgetcsv() doesn't read foreign chracters which are on the beginning of the field.
Similar bug in but it has status closed.

Reproduce code:
File contains:

Example code:
$aqq=fgetcsv($fp, 4000, "|");
echo $aqq[0].$aqq[1].$aqq[2];

Expected result:
Expected result:

Actual result:
Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-06 10:32 UTC]
This example is useles, as we don't know which encoding you are using.
Please put this script in a zip file and provide the link to it in this bugreport.

 [2004-10-06 11:40 UTC] gruszczol1 at poczta dot onet dot pl
It was tested with iso-8859-2 and windows-1250 text file.
 [2004-10-07 01:38 UTC]
Specific to 5.X
 [2004-10-07 17:15 UTC]
Try setting LC_CTYPE (or LANG) environment variable to 
 [2004-10-16 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2005-11-11 13:49 UTC] mdv at inyourpocket dot com
it looks that fgetcsv depends on locales

$argv[1] = './x.txt';

if (!($fd = fopen($argv[1], 'r')))
        die('Can\'t open file');

while (!feof($fd))
        echo fgets($fd, 4096);


if (!($fd = fopen($argv[1], 'r')))
        die('Can\'t open file');

while (($l = fgetcsv($fd, 4096, "\t")))


x.txt get here (text contains text windows-1250 encoding "aa?\t?vvv" \t is TAB)

result when locale POSIX:
aa?    ?vvv
    [0] => aa?
    [1] => vvv

result when locale cs_CZ:
aa?    ?vvv
    [0] => aa?
    [1] => ?vvv
 [2005-11-11 13:53 UTC] mdv at inyourpocket dot com
i tested in on php 5.0.5
 [2008-03-31 09:49 UTC] hkroger at gmail dot com
I can confirm that this still occurs on PHP 5.1.6 on Linux with windows-1250 text files. Please open it again.
 [2009-01-08 12:31 UTC] sandyhbdev at gmail dot com
Thanks moriyoshi,
we can do it by changing LC_CTYPE vriable.
we can read unknown char. from csv if it's begining of value,too

Thank you very much
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Feb 25 17:01:24 2021 UTC