[GIT-PULLS] [php-src] PR #23519: [intl] Fix empty-needle grapheme_strpos offsets
[email protected] (iliaal)
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <[email protected]> |
Pull Request: https://github.com/php/php-src/pull/23519
Author: iliaal
grapheme_strpos() and grapheme_strrpos() with an empty needle return the raw UTF-16 code-unit position instead of a grapheme index, so on a haystack containing a non-BMP or combining grapheme the reported offset is too large: grapheme_strpos("😀x", "", 1) gives 3 where 1 is correct. The empty-needle early return in grapheme_strpos_utf16() skips the grapheme_count_graphemes() conversion that the non-empty search already does. grapheme_strstr() is unaffected: it consumes the separate raw UTF-16 out-parameter, not the return value.