-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mb_substr returns a different value in PHP 8.4 #12972
Comments
It seems behavior changes by #12337 |
I added one more weird behavior of <?php
var_dump(mb_substr('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum dapibus feugiat ex non cursus. Pellentesque vestibulum tellus sit lectus.', 19, -1)); Resulted in this output (Note the end of the result string):
But I expected this output instead:
https://3v4l.org/B0sf5 |
Hi @alexdowad. Looks like this is related to your recent changes to mbstring. |
@MauricioFauth Thanks very much. Change #1 is indeed related to my recent changes to mbstring, and it is the expected behavior. The test string which you kindly provided ( So for point 1, the best things you can do are: A) explicitly specify the text encoding for your string when calling Change #2 is clearly a bug, and it is not caused by the recent changes to mbstring! The recent changes to mbstring just revealed the bug, because it is now affecting UTF-8 strings, whereas before, it would only affect certain other legacy text encodings. The bug was introduced in So, @MauricioFauth, thank you for finally finding my mistake after 14 long months. Your test case will be added to the PHP test suite as a regression test. |
Description
The following code:
Resulted in this output:
But I expected this output instead:
https://3v4l.org/KZrMo
https://3v4l.org/KZrMo/rfc#vgit.master
https://3v4l.org/B0sf5
https://3v4l.org/B0sf5/rfc#vgit.master
PHP Version
PHP 8.4 cffdeb8 (This is the commit I tested, not necessarily the one that introduced the issue.)
Operating System
Debian Trixie
The text was updated successfully, but these errors were encountered: