Bug #48507 [Com]: fgetcsv() ignoring special characters

From: Date: Thu, 26 Jan 2012 19:55:01 +0000
Subject: Bug #48507 [Com]: fgetcsv() ignoring special characters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-166828@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=48507&edit=1

 ID:                 48507
 Comment by:         eswald at middil dot com
 Reported by:        krynble at yahoo dot com dot br
 Summary:            fgetcsv() ignoring special characters
 Status:             Bogus
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Unix
 PHP Version:        5.*
 Block user comment: N
 Private report:     N

 New Comment:

Tested with LANG=C, input file encoding of UTF-8.
Also tested with LANG=C, input file encoding of cp1252, with identical results, 
except that the output characters (what was left of them) were also cp1252.


Previous Comments:
------------------------------------------------------------------------
[2012-01-26 19:50:26] eswald at middil dot com

Confirmed with php5 (5.3.6-13ubuntu3.2 on Oneiric Ocelot); can be worked around 
by quoting the value with quotation marks.  For example, the line

   
a,"a",é,"é",óú,"óú",ó&ú,"ó&ú"

yields

    array (
      0 => 'a',
      1 => 'a',
      2 => '',
      3 => 'é',
      4 => '',
      5 => 'óú',
      6 => '&ú',
      7 => 'ó&ú',
    )

Note the corruption in elements 2, 4, and 6, but not in their quoted 
counterparts 3, 5, and 7.

------------------------------------------------------------------------
[2012-01-18 11:53:48] tero dot tasanen at gmail dot com

I can also confirm that this is an actual bug. File encoding UTF-8, locale 
settings are set correctly and characters like äöå are dropped from the beginning 
of the csv column. 

Tested with php versions 5.2.6, 5.2.10, 5.3.6

------------------------------------------------------------------------
[2011-10-28 08:33:25] peter dot e dot lind at gmail dot com

This is definitely still a bug - my locale is set to da_DK.utf8, the file I'm 
trying to read is in UTF8 (confirmed with a hex-editor but in fact does not 
matter - the behaviour is the same, UTF8 or ISO-8859-1) yet special characters 
are still thrown away when they are first in a field

------------------------------------------------------------------------
[2011-10-18 13:59:30] me at monicag dot it

Quoting my fellows above: how comes this is not a bug?

------------------------------------------------------------------------
[2011-10-10 10:03:58] ghosh at q-one dot com

Sorry. I don't understand why this isn't a bug either. Could someone please elaborate? I
tried setting all different kinds of locale to no avail. The first letter of a string starting with
a UTF-8 character is always missing. IMHO, fgetcsv should work as a simple string operation (or -
whatever weird things it does right now - at least have a parameter to do so - count this as a
feature request if you wish). I think, the current behavior is totally confusing. For instance, I
don't understand why only the first character is missing but the problem doesnt appear if a
character is in the middle of a string.

------------------------------------------------------------------------


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=48507


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=48507&edit=1


Thread (27 messages)

« previous php.bugs (#166828) next »