-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Open
Description
Laravel Version
12.21.0
PHP Version
8.4.1
Database Driver & Version
No response
Description
Use of Illuminate\Support\Str::substrReplace() does not seem to be multibyte aware.
Source line seems to use non-multibyte safe PHP method substr_replace():
https://github.com/laravel/framework/blob/12.x/src/Illuminate/Support/Str.php#L1748
I don't argue that Str would mention somewhere being multibyte safe, but would it make sense to at least mention which methods are not or either rewrite this to be safe like majority of the methods seems to be?
Steps To Reproduce
Using thinker:
> str('kenka')->substrReplace('ng', -3, 2)
= Illuminate\Support\Stringable {#6231
value: "kenga",
}
> str('kenkä')->substrReplace('ng', -3, 2)
= Illuminate\Support\Stringable {#6233
value: b"kenng¤",
}
Expected:
str('kenkä')->substrReplace('ng', -3, 2)->value;
// Result: "kengä"
Metadata
Metadata
Assignees
Labels
No labels