Edit report at https://bugs.php.net/bug.php?id=77025&edit=1
ID: 77025
User updated by: vs-php-bugs at schukai dot com
Reported by: vs-php-bugs at schukai dot com
Summary: mb_strpos throws Unknown encoding or conversion
error
Status: Closed
Type: Bug
Package: mbstring related
Operating System: debian/stretch
PHP Version: 7.3.0RC3
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
yes, that seems to be the case at 7.2.
$A = "\xc4"; // Ã in ISO-8859-1
$a = "\xe4"; // ä in ISO-8859-1
echo mb_stripos($a, $A, 0, '8bit'); // 0
I think that at 8bit (strpos) no conversion should take place:
echo mb_strpos($a, $A, 0, '8bit'); // false
Previous Comments:
------------------------------------------------------------------------
[2018-10-17 10:41:09] nikic@php.net
Automatic comment on behalf of nikita.ppv@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=56665a1b17b8877164473872b90b68d5ac311306
Log: Fixed bug #77025
------------------------------------------------------------------------
[2018-10-17 10:00:12] nikic@php.net
I'm wondering what the meaning of the 8bit encoding is actually supposed to be. Right now, it
essentially seems to be behave the same as ISO-8859-1. It maps code units \x00-\xFF to Unicode
codepoints U+0 - U+FF, which will then also be subject to case-conversions as such:
$A = "\xc4"; // Ã in ISO-8859-1
$a = "\xe4"; // ä in ISO-8859-1
echo mb_stripos($a, $A, 0, '8bit'); // 0
Is it supposed to work that way?
------------------------------------------------------------------------
[2018-10-17 07:47:12] cmb@php.net
Confirmed: <https://3v4l.org/ak195>
------------------------------------------------------------------------
[2018-10-16 22:01:56] vs-php-bugs at schukai dot com
Description:
------------
the following code works as expected
php7.2 -r "echo \mb_stripos('Hello', 'e', 0, '8bit');"
> 1
in 7.3, however, a error is thrown
php7.3 -r "echo \mb_strpos('Hello', 'e', 0, '8bit');"
> php error
alternatively, mb_stripos does not write any output
php7.3 -r "echo \mb_stripos('Hello', 'e', 0, '8bit');"
> empty result
the following code works with iso-8859-1
php7.3 -r "echo \mb_stripos('Hello', 'e', 0, 'iso-8859-1');"
php7.3 -r "print_r(mb_list_encodings());" contains 8bit and iso-8859-1
Array
(
[0] => pass
[1] => auto
[2] => wchar
[3] => byte2be
[4] => byte2le
[5] => byte4be
[6] => byte4le
[7] => BASE64
[8] => UUENCODE
[9] => HTML-ENTITIES
[10] => Quoted-Printable
[11] => 7bit
[12] => 8bit
[13] => UCS-4
[14] => UCS-4BE
7.2/php.ini and 7.3/php.ini are identical
PHP-Version
PHP 7.3.0RC3 (cli) (built: Oct 15 2018 12:05:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.0-dev, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.0RC3, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.7.0beta1, Copyright (c) 2002-2018, by Derick Rethans
Test script:
---------------
echo \mb_strpos('Hello', 'e', 0, '8bit');
Expected result:
----------------
1
Actual result:
--------------
PHP Warning: mb_strpos(): Unknown encoding or conversion error in Command line code on line 1
PHP Stack trace:
PHP 1. {main}() Command line code:0
PHP 2. mb_strpos() Command line code:1
Warning: mb_strpos(): Unknown encoding or conversion error in Command line code on line 1
Call Stack:
0.0008 406848 1. {main}() Command line code:0
0.0008 406848 2. mb_strpos() Command line code:1
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77025&edit=1