Re: [RFC] Deprecate and Remove utf8_encode and utf8_decode

From: Date: Mon, 21 Feb 2022 16:29:53 +0000
Subject: Re: [RFC] Deprecate and Remove utf8_encode and utf8_decode
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-117104@lists.php.net to get a copy of this message
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>

« previous php.internals (#117104) next »