#46217 [Opn]: "fgetcsv" parses a csv file in the greek encoding incorrectly.

From: Date: Thu, 02 Oct 2008 12:34:57 +0000
Subject: #46217 [Opn]: "fgetcsv" parses a csv file in the greek encoding incorrectly.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129415@lists.php.net to get a copy of this message
ID: 46217 User updated by: brook73 at gmail dot com Reported By: brook73 at gmail dot com Status: Open Bug Type: Filesystem function related Operating System: Ubuntu 8.04 PHP Version: 5.2.6 New Comment: Re: 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 Expected 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] => ) Previous Comments: ------------------------------------------------------------------------ [2008-10-02 12:20:44] brook73 at gmail dot com 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 this bug report at http://bugs.php.net/?id=46217&edit=1

« previous php.bugs (#129415) next »