From:             bugs dot php dot net_alex at gareis dot info
Operating system: Linux (Debian)
PHP version:      5.1.4
PHP Bug Type:     Filesystem function related
Bug description:  fgetcsv strips certain characters from beginning of a field 
if not quoted

Description:
------------
Despite the correct locale settings, fgetcsv strips characters from the
beginning of a field, if the field is not quoted correctly.

Reproduced with PHP 5.1.2-Debian-0.1~sarge1, PHP 5.1.4-1.dotdeb.2, locales
en_US, en_US.UTF-8, POSIX.

NOT reproduced with PHP 5.0.5-2ubuntu1.2 (en_US.UTF-8),
5.1.4-Debian-0.1~sarge1 (en_US)

Might actually not be a bug, but a documentation problem - however, i do
not think this related to the similar bug reports present.

Reproduce code:
---------------
#!/usr/local/bin/php -Cq
<?php

if (is_file('temp')) die("temp!\n");

$fcontent = 'foo,öbar,®¯°ä»,"öbar","®¯°ä»"';
file_put_contents('temp', $fcontent);
echo 'plain: '.file_get_contents('temp')."\n\nfgetcsv: ";
$fp = fopen('temp', 'r');
print_r(fgetcsv($fp, 1024, ',', '"'));
fclose($fp);
unlink('temp');

?>


Expected result:
----------------
plain: foo,öbar,®¯°ä»,"öbar","®¯°ä»"

fgetcsv: Array
(
    [0] => foo
    [1] => öbar
    [2] => ®¯°ä»
    [3] => öbar
    [4] => ®¯°ä»
)


Actual result:
--------------
plain: foo,öbar,®¯°ä»,"öbar","®¯°ä»"

fgetcsv: Array
(
    [0] => foo
    [1] => bar
    [2] =>
    [3] => öbar
    [4] => ®¯°ä»
)


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

Reply via email to