Edit report at https://bugs.php.net/bug.php?id=46217&edit=1
ID: 46217
Comment by: erwin32 dot 64 at gmail dot com
Reported by: brook73 at gmail dot com
Summary: fgetcsv() parses a csv file in the greek encoding
incorrectly
Status: No Feedback
Type: Bug
Package: Filesystem function related
Operating System: Ubuntu 8.04
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
try setlocale(LC_ALL, 'el_GR') instead setlocale(LC_ALL, 'gr_GR') greek
language
is el and state is GR
Previous Comments:
------------------------------------------------------------------------
[2008-11-03 01:00:03] 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-10-26 19:17:21] [email protected]
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2008-10-20 17:24:08] mike at regexia dot com
(This is my first attempt at fixing a bug, so please bear with me. :))
Patch available here: http://www.regexia.com/php/bug46217/bug46217.diff
Test case as well: http://www.regexia.com/php/bug46217/bug46217.phpt
Explanation:
The initial pass on a field tries to skip whitespace. If php_mblen() returns -2
or -1 that character is skipped (as if it's whitespace). Regardless of locale,
non-ASCII characters were returning -1 (invalid). My patch treats those
characters as regular non-WS characters. This behavior seems to be consistent
with non-ASCII handling in the middle of a CSV field.
Enclosing the CSV field data in a quote or the like works around the issue.
Hope this is clear and the correct protocol for submitting this patch. :)
Mike
------------------------------------------------------------------------
[2008-10-02 13:23:21] brook73 at gmail dot com
Please use this file
http://dev.cs-cart.com/~brook/test.csv
------------------------------------------------------------------------
[2008-10-02 12:34:56] brook73 at gmail dot com
Re:
Example of the line in csv file:
ΓΟΜ000112;Είδη
Γραφής -
Διόρθωσης///Γόμες;1.30;1.30;30
Sep 2008
00:00:00;N;ΘΡΥΛΟΣ3;ΕΑΕΕΑΕΑΕΕΑΕΑΕΑΕ
Expected result:
Debug [0/0]:Array
(
[0] => ΓΟΜ000112
[1] => Είδη Γραφής -
Διόρθωσης///Γόμες
[2] => 1.30
[3] => 1.30
[4] => 30 Sep 2008 00:00:00
[5] => N
[6] => ΘΡΥΛΟΣ3
[7] =>
ΕΑΕΕΑΕΑΕΕΑΕΑΕΑΕ
)
Actual result
Expected result:
Debug [0/0]:Array
(
[0] => 000112
[1] => -
Διόρθωσης///Γόμες
[2] => 1.30
[3] => 1.30
[4] => 30 Sep 2008 00:00:00
[5] => N
[6] => 3
[7] =>
)
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=46217
--
Edit this bug report at https://bugs.php.net/bug.php?id=46217&edit=1