php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40811 fgetcsv() strange behaviour
Submitted: 2007-03-15 08:33 UTC Modified: 2008-07-25 01:00 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: websites at mtu-net dot ru Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.1 OS: Linux
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: websites at mtu-net dot ru
New email:
PHP Version: OS:

 

 [2007-03-15 08:33 UTC] websites at mtu-net dot ru
Description:
------------
When opening an .csv-file with fgetcsv() most part of cyrillic (win-1251) characters disappears, and they are returned as an empty string in returned list. Everything's OK with latin characters.

Reproduce code:
---------------
$fp=fopen("csv.csv","r");
while ($arr=fgetcsv($fp, 1000, ";"))
 {
  *here comes a bunch of outputs*

Expected result:
----------------
Expected: all strings neatly packed in a list =)

Actual result:
--------------
Result: almost all string fields in a list are empty

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-15 13:01 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2007-03-23 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".
 [2008-05-13 10:28 UTC] great_boba at yahoo dot com
Try to use setlocale
 [2008-07-17 15:37 UTC] nospam at earth dot net
code to reproduce the bug:

<?php

// setlocale(LC_ALL, 'ru_RU.cp1251');

$row = 1;
$handle = fopen("p.csv", "r");
while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
    $num = count($data);
    echo "<p> $num fields in line $row: <br /></p>\n";
    $row++;
    for ($c=0; $c < $num; $c++) {
    echo $data[$c] . "<br />\n";
    }
}
fclose($handle);
?>
 [2008-07-17 15:53 UTC] nospam at earth dot net
setlocale doesn't help.
p.csv can be any csv file under cyrillic win-1251
 [2008-07-17 16:52 UTC] moriyoshi@php.net
Make sure cp1251 is a supported charmap in your system. You can check it 
by feeding -a option to /usr/bin/locale .



 [2008-07-25 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".
 [2009-06-18 14:39 UTC] crashdown at hot dot ee
If you put cyrillic text between double-quotes, then all be okey.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC