On Mon, Feb 21, 2022 at 03:52:57PM +0000, Craig Francis wrote: > I would personally encourage everyone to have ext/intl installed and use > > grapheme_strlen() instead of mb_strlen(), because knowing whether a > > particular instance of the string "Nguyễn" is written with 6, 7, or 8 > > code points is not nearly as useful as knowing that it looks like 6 > > "characters" to a user either way.
Looking at the description of grapheme_strlen() I note that it can return null. However it does not say why. https://www.php.net/manual/en/function.grapheme-strlen.php Digging in the code I see that it will return null if intl_convert_utf8_to_utf16() fails. I think because of one of: U_BUFFER_OVERFLOW_ERROR means that *target buffer is not large enough U_STRING_NOT_TERMINATED_WARNING usually means that the input string is empty u_strFromUTF8() failing. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 https://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: https://www.phcomp.co.uk/Contact.html #include <std_disclaimer.h> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php