Doc #78190 [Com]: mb_split now return false with ISO strings
Edit report at https://bugs.php.net/bug.php?id=78190&edit=1
ID: 78190
Comment by: Isaac1866Williams at gmail dot com
Reported by: mvachette at adequasys dot com
Summary: mb_split now return false with ISO strings
Status: Re-Opened
Type: Documentation Problem
Package: mbstring related
Operating System: Windows 10
PHP Version: 7.2.19
Block user comment: N
Private report: N
New Comment:
Hello,
In the case of failure to perform preg_split due to invalid inputs, preg_split will return false.
Example-
$string = array("sdasds"); // Invalid string
$array=preg_split('/[\s,]+/',$string);
var_dump($array); //false
$string = "sdasds";
$array=preg_split('j',$string); // Invalid pattern
var_dump($array); //false
(https://www.mycenturahealth.me/)github.com
Previous Comments:
------------------------------------------------------------------------
[2019-06-20 15:47:19] nikic@php.net
Right, this should probably be documented. This change was backported in https://github.com/php/php-src/commit/0ecac37c40a27ffbd59f34b5920735ee0b7f994c#diff-3b307ca282b8a468c86220f768eea0d7
which is in 7.1.28, 7.2.18 and 7.3.5. For other mb_regex functions apart from mb_split and
mb_ereg_match this was already checked previously, though I'm not sure since when.
------------------------------------------------------------------------
[2019-06-20 15:30:40] mvachette at adequasys dot com
Ok, I figure to clear the error using mb_regex_encoding, thanks for the suggestion.
But is there any documentation available about this change of behaviour? For information, I found
this burried into Smarty lib. I can ensure correct behaviour of mb_split on my app, by maybe I will
not be the lone to be impacted.
------------------------------------------------------------------------
[2019-06-20 15:21:27] nikic@php.net
The default encoding is UTF-8, use mb_regex_encoding() if you are working with something else.
------------------------------------------------------------------------
[2019-06-20 15:15:44] sjon@php.net
I cannot reproduce this, it seems to work pretty consistently: https://3v4l.org/QqYjC
------------------------------------------------------------------------
[2019-06-20 15:09:11] mvachette at adequasys dot com
Description:
------------
It seems that something changes in 7.2.18 when using mb_split on ISO string.
On at least 7.2.16 & 7.2.17, using this function with ISO encoding string containing accents
works fine.
On a new env with version 7.2.18, the same code now return "false" (new undocumented
behaviour)
Test script:
---------------
var_dump(mb_split('-', 'e-a'));
//works fine on any version
var_dump(mb_split('-', 'é-a'));
// works if string is UTF8 encoded
// return "false" with an ISO encoded string on PHP 7.2.18
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78190&edit=1
Thread (2 messages)