Re: Introduce str_left/right In 8.1

From: Date: Wed, 23 Jun 2021 21:54:32 +0000
Subject: Re: Introduce str_left/right In 8.1
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-115080@lists.php.net to get a copy of this message
On 23/06/2021 22:28, Christoph M. Becker wrote:
substr() is about bytes, not characters. They all may have upvoted the wrong answer. The only correct answer has just 17 upvotes.
Just to out-pedant you, I'll point out that what most people would think of as a "character" is neither a byte nor a code point, but a grapheme, so I would say *none* of the answers on that page is correct. $string = 'Zoë'; // "Zoe\u{0308}" not "Zo\u{00EB}" var_dump(substr($string, -1)); var_dump(mb_substr($string, -1)); var_dump(grapheme_substr($string, -1)); string(1) "�" string(2) "̈" string(3) "ë" https://3v4l.org/IMoWQ Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#115080) next »