Bug->Doc #81284 [Nab->Opn]: str_getcsv cant parse with multibyte delimiter

From: Date: Fri, 23 Jul 2021 13:23:53 +0000
Subject: Bug->Doc #81284 [Nab->Opn]: str_getcsv cant parse with multibyte delimiter
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18984@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81284&edit=1

 ID:                 81284
 Updated by:         cmb@php.net
 Reported by:        mx03 at volny dot cz
 Summary:            str_getcsv cant parse with multibyte delimiter
-Status:             Not a bug
+Status:             Open
-Type:               Bug
+Type:               Documentation Problem
 Package:            Strings related
 PHP Version:        Irrelevant
-Assigned To:        cmb
+Assigned To:        
 Block user comment: N
 Private report:     N

 New Comment:

Well, documentation says "one character", what is misleading.


Previous Comments:
------------------------------------------------------------------------
[2021-07-23 13:22:22] cmb@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

------------------------------------------------------------------------
[2021-07-23 13:01:13] mx03 at volny dot cz

Description:
------------
Separator can be only one character that is not multibyte.

if setlocale is utf8, it cant parse the csv:
https://3v4l.org/MiD3B

if setlocale is not utf8, it parses the string, but the result has the 2 additional bytes:
https://3v4l.org/ohc4Q

Test script:
---------------
setlocale(LC_CTYPE, "en_US.UTF-8");

$test = "❤";

$line = "test1❤test2❤test3";
$header = str_getcsv($line, $test);
var_dump($header);

Expected result:
----------------
array(3) {
  [0]=>
  string(5) "test1"
  [1]=>
  string(7) "test2"
  [2]=>
  string(7) "test3"
}

Actual result:
--------------
array(1) {
  [0]=>
  string(21) "test1❤test2❤test3"
}


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



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


Thread (3 messages)

« previous php.doc.bugs (#18984) next »