Bug #79238 [NEW]: preg_split returns weird results
From: vuongvankhanh89 at gmail dot com
Operating system: Ubuntu 18.04
PHP version: 7.4.2
Package: PCRE related
Bug Type: Bug
Bug description:preg_split returns weird results
Description:
------------
Hi, today i created a pattern to separate text to an array.
Regex string is very simple:
preg_split('/\R| /m',
'ç¿¶èåè
èç¿¶èååå Xèèè')
it detects whitespace and linebreak as the separators and then converts
string to array of strings.
in the exam above there is no whitespace or linebreak but result i got
is an array with 2 elements.
array(2) {
[0]=>
string(11) "ç¿¶èå�"
[1]=>
string(28) "èç¿¶èååå Xèèè"
}
è
has been turned to a separator, it also becomes a weird charactor.
Kindly help! Thanks in advance.
Test script:
---------------
var_dump(preg_split('/\R| /m',
'ç¿¶èåè
èç¿¶èååå Xèèè'));
Expected result:
----------------
array(1) {
[0]=>
string(39)
"ç¿¶èåè
èç¿¶èååå Xèèè"
}
Actual result:
--------------
array(2) {
[0]=>
string(11) "ç¿¶èå�"
[1]=>
string(28) "èç¿¶èååå Xèèè"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=79238&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79238&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79238&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79238&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79238&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79238&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79238&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79238&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79238&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79238&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79238&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79238&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79238&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79238&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79238&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79238&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79238&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79238&r=mysqlcfg
Thread (2 messages)
- vuongvankhanh89 at gmail dot com