On 21.02.2022 at 18:35, Rowan Tommins wrote:

> On 21/02/2022 16:29, Alain D D Williams wrote:
>
>> Looking at the description of grapheme_strlen() I note that it can
>> return null.
>> However it does not say why>
> Huh, that feels like a bug to me, since it can also return false, which
> is the more standard way of indicating failure.

This is not the only function which returns null or false for different
kinds of failures.

> The obvious failure case is an input string that's not valid UTF-8, e.g.
> grapheme_strlen("\xFF"). It appears that currently returns null; so I'm
> not actually sure how you'd trigger the false case.

false is returned, if the internal function
grapheme_get_break_iterator() fails.  I'm not sure under which
circumstances that function may fail, but from looking at the code and
the ICU documentation[1], it seems we're relying on functionality which
is deprecated as of ICU 52; it's probably a good idea to adjust the
code, and to possibly bump the ICU version requirements (currently, ICU
>= 50.1 is required).

[1]
<https://unicode-org.github.io/icu-docs/apidoc/dev/icu4c/ubrk_8h.html#ad1917029dcd00164d18e9d77b73be195>

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to