[php-src] PR #12459: [RFC] Add trim for multibyte function
| From: | youkidearitai | Date: | Tue, 17 Oct 2023 15:14:47 +0000 |
| Subject: | [php-src] PR #12459: [RFC] Add trim for multibyte function | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-23912@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12459
Author: youkidearitai
Related: #9216
I make a propose a multibyte version of the trim function.
```
function mb_trim(string $string, string $characters = "
\f\n\r\t\v\x00\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}",
?string $encoding = null): string {}
function mb_ltrim(string $string, string $characters = "
\f\n\r\t\v\x00\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}",
?string $encoding = null): string {}
function mb_rtrim(string $string, string $characters = "
\f\n\r\t\v\x00\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}",
?string $encoding = null): string {}
```
On the other hand, The ".." notation for
$characters that was in the trim
function was not supported. ex: \u{0000}..\u{FFFF}
Because the reason is below:
- Unicode character is very wide
- Difficult to search
- Difficult to store in memory
At later, I'll writing to RFC. Just a moment.