Re: [Discussion] grapheme cluster for str_split function
| From: | Niels Dossche | Date: | Mon, 04 Mar 2024 19:17:41 +0000 |
| Subject: | Re: [Discussion] grapheme cluster for str_split function | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-122553@lists.php.net to get a copy of this message | ||
Hi Yuya
This sounds useful.
I do have a question about the function signature:
function grapheme_str_split(string $string, int $length = 1): array {}
This always returns an array.
However, looking at your PR it seems you return NULL on failure, but the return type in the
signature isn't nullable.
Also, from a quick look, it seems other functions return false instead of null on failure. So
perhaps the return type should be array|false.
What do you think? :)
Kind regards
Niels
On 03/03/2024 00:21, youkidearitai wrote:
> Hi, Internals
>
> I noticed PHP does not have grapheme cluster for str_split function.,
> Until now, you had to use the PCRE function's \X.
>
> Therefore, I try create
grapheme_str_split function.
> https://github.com/php/php-src/pull/13580
> It is possible to convert array per emoji and variation selectors using ICU.
>
> If it's fine, I'll create an RFC.
>
> Regards
> Yuya
>