I know that there is no mb_trim version of the trim. I have links to the dozen of articles for how to implement one using preg_replace.
The question I have, is the usual trim with default chars mb safe? That is, is there any example of multibyte character that ends with single byte whitespace char code?
Since characters in default character mask (whitespace+\t\n\r\0\x0B) are ASCII, it is safe to use trim() with multibute string.
trim(' 漢字は '); // ok
Character mask with multibyte characters will cause problems.
trim('はは漢字はは', 'は'); // bad
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With