[DISCUSSION] grapheme_* functions adds locale in parameter (or any?)

php.internals

youkidearitai

1 year ago
Hi, Internals I would like adds locale parameter that already there are grapheme_* functions. Because Unicode is locale-dependency but grapheme_* functions is not locale-dependency. For example, Add $locale parameter is below. ``` grapheme_extract( string $haystack, int $size, int $type = GRAPHEME_EXTR_COUNT, int $offset = 0, int &$next = null, string ?$locale = null ): string|false grapheme_str_split(string $string, int $length = 1, string ?$locale = null): array|false grapheme_stripos(string $haystack, string $needle, int $offset = 0, string ?$locale = null): int|false grapheme_stristr(string $haystack, string $needle, bool $beforeNeedle = false, string ?$locale = null): string|false grapheme_strlen(string $string, ?string $locale = null): int|false|null grapheme_strpos(string $haystack, string $needle, int $offset = 0, string ?$locale = null): int|false grapheme_strripos(string $haystack, string $needle, int $offset = 0, string ?$locale = null): int|false grapheme_strrpos(string $haystack, string $needle, int $offset = 0, string ?$locale = null): int|false grapheme_strstr(string $haystack, string $needle, bool $beforeNeedle = false, ?$locale = null): string|false grapheme_substr(string $string, int $offset, ?int $length = null, ?string ?$locale = null): string|false ``` What do you think? I would like go to write an RFC if this is fine. Regards Yuya
-- --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------

Claude Pache

1 year ago
> Le 5 juin 2025 à 03:04, youkidearitai <youkidearitai@gmail.com> a écrit : > > Hi, Internals > > I would like adds locale parameter that already there are grapheme_* functions. > Because Unicode is locale-dependency but grapheme_* functions is not > locale-dependency. > > For example, Add $locale parameter is below. > ``` > grapheme_extract( > string $haystack, > int $size, > int $type = GRAPHEME_EXTR_COUNT, > int $offset = 0, > int &$next = null, > string ?$locale = null > ): string|false > grapheme_str_split(string $string, int $length = 1, string ?$locale = > null): array|false > grapheme_stripos(string $haystack, string $needle, int $offset = 0, > string ?$locale = null): int|false > grapheme_stristr(string $haystack, string $needle, bool $beforeNeedle > = false, string ?$locale = null): string|false > grapheme_strlen(string $string, ?string $locale = null): int|false|null > grapheme_strpos(string $haystack, string $needle, int $offset = 0, > string ?$locale = null): int|false > grapheme_strripos(string $haystack, string $needle, int $offset = 0, > string ?$locale = null): int|false > grapheme_strrpos(string $haystack, string $needle, int $offset = 0, > string ?$locale = null): int|false > grapheme_strstr(string $haystack, string $needle, bool $beforeNeedle = > false, ?$locale = null): string|false > grapheme_substr(string $string, int $offset, ?int $length = null, > ?string ?$locale = null): string|false > ``` > > What do you think? > I would like go to write an RFC if this is fine. > > Regards > Yuya >
Hi, A $locale parameter could be added for functions that are locale-dependant: grapheme_stripos() ,grapheme_stristr(), grapheme_strripos(), and more generally to any function that deals with casing. It doesn’t make sense for the other functions. —Claude

youkidearitai

1 year ago
2025年6月5日(木) 18:02 Claude Pache <claude.pache@gmail.com>:
> > > > > Le 5 juin 2025 à 03:04, youkidearitai <youkidearitai@gmail.com> a écrit : > > > > Hi, Internals > > > > I would like adds locale parameter that already there are grapheme_* functions. > > Because Unicode is locale-dependency but grapheme_* functions is not > > locale-dependency. > > > > For example, Add $locale parameter is below. > > ``` > > grapheme_extract( > > string $haystack, > > int $size, > > int $type = GRAPHEME_EXTR_COUNT, > > int $offset = 0, > > int &$next = null, > > string ?$locale = null > > ): string|false > > grapheme_str_split(string $string, int $length = 1, string ?$locale = > > null): array|false > > grapheme_stripos(string $haystack, string $needle, int $offset = 0, > > string ?$locale = null): int|false > > grapheme_stristr(string $haystack, string $needle, bool $beforeNeedle > > = false, string ?$locale = null): string|false > > grapheme_strlen(string $string, ?string $locale = null): int|false|null > > grapheme_strpos(string $haystack, string $needle, int $offset = 0, > > string ?$locale = null): int|false > > grapheme_strripos(string $haystack, string $needle, int $offset = 0, > > string ?$locale = null): int|false > > grapheme_strrpos(string $haystack, string $needle, int $offset = 0, > > string ?$locale = null): int|false > > grapheme_strstr(string $haystack, string $needle, bool $beforeNeedle = > > false, ?$locale = null): string|false > > grapheme_substr(string $string, int $offset, ?int $length = null, > > ?string ?$locale = null): string|false > > ``` > > > > What do you think? > > I would like go to write an RFC if this is fine. > > > > Regards > > Yuya > > > > Hi, > > A $locale parameter could be added for functions that are locale-dependant: grapheme_stripos() ,grapheme_stristr(), grapheme_strripos(), and more generally to any function that deals with casing. > > It doesn’t make sense for the other functions. > > —Claude > >
Hi, Claude and Internals Thank you for your feedback. Indeed, I keep only locale is case-sensitive. However, I watched that RFC: https://wiki.php.net/rfc/strtolower-ascii and https://github.com/php/php-src/pull/7511, Perhaps, I should not locale-dependant for grapheme functions. I'll think about it more deeply. Please give me a time. Regards Yuya
-- --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------

Claude Pache

1 year ago
> > However, I watched that RFC: https://wiki.php.net/rfc/strtolower-ascii > and https://github.com/php/php-src/pull/7511, > Perhaps, I should not locale-dependant for grapheme functions.
Note that this RFC was about making the functions independent from the global mode as set by `setlocale()`. There is no issue in adding an explicit $locale parameter to those functions if the default value doesn’t depend on a global state. —Claude

youkidearitai

1 year ago
> Note that this RFC was about making the functions independent from the global mode as set by `setlocale()`. > > There is no issue in adding an explicit $locale parameter to those functions if the default value doesn’t depend on a global state. > > —Claude >
Hi, Claude Thanks for the comment. I see, I will try add $locale parameter to the minimum. Just a moment, please. Regards Yuya
-- --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------

youkidearitai

1 year ago
Hi, Internals I created an RFC and Draft PR. - https://wiki.php.net/rfc/grapheme_add_locale_for_case_insensitive - https://github.com/php/php-src/pull/18792 I would like to discussion. Feel free to comment. Regards Yuya
-- --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------