From:             brook73 at gmail dot com
Operating system: Ubuntu 8.04
PHP version:      5.2.6
PHP Bug Type:     Filesystem function related
Bug description:  "fgetcsv" parses a csv file in the greek encoding incorrectly.

Description:
------------
The "fgetcsv" function parses a file in the greek encoding  (ISO-8859-7)
incorrectly - a lot of symbols are ignored.

The "setlocale" function has not helped either (we tried setlocale(LC_ALL,
'gr_GR'), setlocale(LC_ALL, 'gr_GR.ISO-8895-7')).

Can anyone help us and explain the reason why it happens?

The PHP version is 5.2.5.

Reproduce code:
---------------
<?php

$max_line_size = 16384;
$delimiter = ";";

$f = fopen('somefile.csv', 'rb');

while (($data = fgetcsv($f, $max_line_size, $delimiter)) !== false) {
  print_r($data);
}

?>

Example of the line in csv file:

&#915;&#927;&#924;000112;&#917;&#943;&#948;&#951;
&#915;&#961;&#945;&#966;&#942;&#962; -
&#916;&#953;&#972;&#961;&#952;&#969;&#963;&#951;&#962;///&#915;&#972;&#956;&#949;&#962;;1.30;1.30;30
Sep 2008
00:00:00;N;&#920;&#929;&#933;&#923;&#927;&#931;3;&#917;&#913;&#917;&#917;&#913;&#917;&#913;&#917;&#917;&#913;&#917;&#913;&#917;&#913;&#917;;

Expected result:
----------------
Debug [0/0]:Array
(
    [0] => &#915;&#927;&#924;000112
    [1] => &#917;&#943;&#948;&#951; &#915;&#961;&#945;&#966;&#942;&#962; -
&#916;&#953;&#972;&#961;&#952;&#969;&#963;&#951;&#962;///&#915;&#972;&#956;&#949;&#962;
    [2] => 1.30
    [3] => 1.30
    [4] => 30 Sep 2008 00:00:00
    [5] => N
    [6] => &#920;&#929;&#933;&#923;&#927;&#931;3
    [7] =>
&#917;&#913;&#917;&#917;&#913;&#917;&#913;&#917;&#917;&#913;&#917;&#913;&#917;&#913;&#917;
)


Actual result:
--------------
Debug [0/0]:Array
(
    [0] => 000112
    [1] => -
&#916;&#953;&#972;&#961;&#952;&#969;&#963;&#951;&#962;///&#915;&#972;&#956;&#949;&#962;
    [2] => 1.30
    [3] => 1.30
    [4] => 30 Sep 2008 00:00:00
    [5] => N
    [6] => 3
    [7] => 
)


-- 
Edit bug report at http://bugs.php.net/?id=46217&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=46217&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=46217&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=46217&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=46217&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=46217&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=46217&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=46217&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=46217&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=46217&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=46217&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=46217&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=46217&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=46217&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=46217&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=46217&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=46217&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=46217&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=46217&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=46217&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=46217&r=mysqlcfg

Reply via email to