You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The behavior of mb_strcut in mbstring has been changed in PHP8.1 #9535
When using the mb_strcut function to cut out ISO-2022-JP encoded strings, depending on the number of bytes specified, the behavior is different in PHP 8.1 than before.
Although the behavior is not documented exactly, this looks like a bug. We likely want to truncate partial characters (code points) at the end. This apparently works nicely for UTF-8, see e.g. https://3v4l.org/oZgCU.
Reacted by Tairi Chiba, Ryo Tomidokoro and Yuichi Sugiyama
However, there are other function affected by mb_substitute_character (e.g.: mb_convert_case https://3v4l.org/J7kVC )
For this issue, the 10th byte of 'あaいb' is 0x1b, meaning the escape sequence, then converted ?. (3v4l: https://3v4l.org/Intbd )
I'm curious why mb_substitute_character doesn't work.
If this other subject, then I open new feature request.
@NathanFreeman Thank you for reply.
My question was "Why mb_strcut is doesn't work of mb_substitute_character". But I understand that mb_substitute_character originally (since PHP 4.3.0 https://3v4l.org/s0gbn#v430) doesn't work.
Although the question remains why mb_convert_case is affected by mb_substitute_character which isn't in the manual(3v4l: https://3v4l.org/2lqgg#v430), this is another issue, thank you for your time.
@youkidearitai Can you read C code? I would be happy to point you to the lines in the source code which would answer your question. Or do you just want a high-level answer which does not require delving into the details of the implementation?
@pakutoma Thanks for reporting this issue. It is nice to see that @NathanFreeman is working on a fix. I will try to guide him so he can complete this successfully.
There are some very tricky issues involved with the implementation of mb_strcut, but I think we can work them out.
Just for information, the unexpected change in behavior which you have kindly reported was (indirectly) caused by 4299e2d.
Activity
cmb69 commentedon Sep 14, 2022
Although the behavior is not documented exactly, this looks like a bug. We likely want to truncate partial characters (code points) at the end. This apparently works nicely for UTF-8, see e.g. https://3v4l.org/oZgCU.
youkidearitai commentedon Sep 24, 2022
Hi, I have a question. mb_strcut is unaffected of mb_substitute_character that manual written by below.
However, there are other function affected by mb_substitute_character (e.g.: mb_convert_case https://3v4l.org/J7kVC )
For this issue, the 10th byte of
'あaいb'is 0x1b, meaning the escape sequence, then converted?. (3v4l: https://3v4l.org/Intbd )I'm curious why mb_substitute_character doesn't work.
If this other subject, then I open new feature request.
NathanFreeman commentedon Sep 26, 2022
@youkidearitai Hi.
I think then converted
?is a valid character now somb_substitute_characterdoesn't work.youkidearitai commentedon Sep 26, 2022
@NathanFreeman Thank you for reply.
My question was "Why mb_strcut is doesn't work of
mb_substitute_character". But I understand thatmb_substitute_characteroriginally (since PHP 4.3.0 https://3v4l.org/s0gbn#v430) doesn't work.Although the question remains why
mb_convert_caseis affected bymb_substitute_characterwhich isn't in the manual(3v4l: https://3v4l.org/2lqgg#v430), this is another issue, thank you for your time.alexdowad commentedon Oct 5, 2022
@youkidearitai Can you read C code? I would be happy to point you to the lines in the source code which would answer your question. Or do you just want a high-level answer which does not require delving into the details of the implementation?
@pakutoma Thanks for reporting this issue. It is nice to see that @NathanFreeman is working on a fix. I will try to guide him so he can complete this successfully.
There are some very tricky issues involved with the implementation of
mb_strcut, but I think we can work them out.Just for information, the unexpected change in behavior which you have kindly reported was (indirectly) caused by 4299e2d.
fix php#9535
Fix GH-9535 (unintended behavior change for mb_strcut in PHP 8.1)
Merge branch 'PHP-8.1' into PHP-8.2
Merge branch 'PHP-8.2'
Fix regression test for GH-9535 on PHP-8.2+
Merge branch 'PHP-8.2'
Merge branch 'master' into unserialize-notice-to-warning