Bug #65368 [Opn->Dup]: fgetcsv not working for Unicode delimiter
| From: | yohgaki@php.net | Date: | Fri, 02 Aug 2013 01:03:58 +0000 |
| Subject: | Bug #65368 [Opn->Dup]: fgetcsv not working for Unicode delimiter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180667@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65368&edit=1
ID: 65368
Updated by: yohgaki@php.net
Reported by: gauweiler at epoq dot de
Summary: fgetcsv not working for Unicode delimiter
-Status: Open
+Status: Duplicate
Type: Bug
Package: Filesystem function related
PHP Version: 5.5.1
Block user comment: N
Private report: N
New Comment:
Basically the same issue as #55507
Previous Comments:
------------------------------------------------------------------------
[2013-07-31 15:01:53] gauweiler at epoq dot de
Description:
------------
fgetcsv does not work if you have a unicode delimiter like § (paragraph).
setlocale() doesn't help.
Test script:
---------------
error_reporting(E_ALL);
$enclosure='"';
$escape='"';
$delimiter=",";
$fh = tmpfile();
fwrite($fh,utf8_encode('"first"'.$delimiter.'"second"'.$delimiter.'"third"'."\n"));
fwrite($fh,utf8_encode('"one"'.$delimiter.'"two""two"'.$delimiter.'"three"'."\n"));
fseek($fh,0);
while (($data = fgetcsv($fh, 0, $delimiter,$enclosure,$escape)) !== FALSE) {
print_r($data);
}
fclose($fh);
$delimiter=chr(167); // §
$fh = tmpfile();
fwrite($fh,utf8_encode('"first"'.$delimiter.'"second"'.$delimiter.'"third"'."\n"));
fwrite($fh,utf8_encode('"one"'.$delimiter.'"two""two"'.$delimiter.'"three"'."\n"));
$delimiter=utf8_encode($delimiter);
fseek($fh,0);
while (($data = fgetcsv($fh, 0, $delimiter,$enclosure,$escape)) !== FALSE) {
print_r($data);
}
fclose($fh);
Expected result:
----------------
The line is splitted by unicode delimiter also. No warnings appear.
Array
(
[0] => first
[1] => second
[2] => third
)
Array
(
[0] => one
[1] => two"two
[2] => three
)
Array
(
[0] => first
[1] => second
[2] => third
)
Array
(
[0] => one
[1] => two"two
[2] => three
)
Actual result:
--------------
Warnings appear: "Notice: fgetcsv(): delimiter must be a single character in..."
The line is splitted using , but not using §:
Array
(
[0] => first
[1] => second
[2] => third
)
Array
(
[0] => one
[1] => two"two
[2] => three
)
Array
(
[0] => first§"second"§"third"
)
Array
(
[0] => one§"two""two"§"three"
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65368&edit=1