Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115098 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39268 invoked from network); 24 Jun 2021 07:37:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jun 2021 07:37:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A9A35180508 for ; Thu, 24 Jun 2021 00:56:20 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 24 Jun 2021 00:56:20 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id p7so8745123lfg.4 for ; Thu, 24 Jun 2021 00:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SbsnBZHyVgeK143M44kjm8ru4ABmVuZH9Oo5Se00JzQ=; b=Q/cCV2RlhZ8b4wAtsSYY/UJrPD2JotkOej0MyRw3Cy7mCgoR8qPZhAu0Vo2rqScwSm B9ampF22OMuteuWb53CsXjE7tj/wEi1+GLkJDbbi6kozPvApF9fEWz/4O0U3A/l9yWOn qaeAJRpPsUT+VY87gZomourr0vKZK+mT16Ay5cKmpoLFTNuRRJYSYuXHINT+hBgX9PDX 8aTy9MvKlnFHap1Zz9ekT0GfI+o6wUq/mIMki4XIuAYHM2BUhEpG2VgO9Q7ZuOCr2RL1 YaJsGzKpM38zdKxgFgpW9a6FSwuz91G87Av+lTvb6GhaTbQTCxKKBFDKB5uKbLfRkIlw x1/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SbsnBZHyVgeK143M44kjm8ru4ABmVuZH9Oo5Se00JzQ=; b=qpV11pu/6K+1s9vQ9sBhq09QLWFeMHJ+0LHvIZTjWSF7IbT8eBgZ92JoYlisMTKcpz 9GpFHKvItcEqDGexKb0k+mPHTIbNFIJLmUaPFNNRVRnkRrPTuWv1QmvAHOQa9eEFd34G AmHtc9CIyRiNCTSCiOiPgg1+nOSeqve6b6206VZLVyIxMy3C5QiLRyJeZx3a6DKXJvks ZW21WIpRrOw5alYSSXnMlg5YFuu/TiB8Kj2hYEfGrgRx0VPnlNT1JVsw7FT6NUkQc5BP POLXYnvJJg60GFLgUQPBRYxvTng952aAidPjPjOdgAErD9bDz9mXC8NY2J4vjQJyGtyN RcPA== X-Gm-Message-State: AOAM530au1z17lfzRuOCalctGqKEtLv+N170Swq0Bg7MYmLlonSPdZm9 nkfHx/SukPZsrtcYwqLvogs/KKMDJc5W6mFuJg== X-Google-Smtp-Source: ABdhPJwVDPUinzqGnKBT5ophzrITgZxSwdQBnaizVgheHygmhPKnCZpro/a4RijarBHISGnOh1oZgZ+ppb/Fn4Dq4eE= X-Received: by 2002:a05:6512:169f:: with SMTP id bu31mr2917814lfb.486.1624521376146; Thu, 24 Jun 2021 00:56:16 -0700 (PDT) MIME-Version: 1.0 References: <012901d7683a$446a7ba0$cd3f72e0$@gmail.com> <7e2b946f-c302-5350-a6e6-1e06802c95a5@gmx.de> <5bbec9d0-aeb8-9ff7-fdf1-4c38d78cb624@gmail.com> In-Reply-To: <5bbec9d0-aeb8-9ff7-fdf1-4c38d78cb624@gmail.com> Date: Thu, 24 Jun 2021 09:56:05 +0200 Message-ID: To: Rowan Tommins Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000008e292905c57e5b26" Subject: Re: [PHP-DEV] Introduce str_left/right In 8.1 From: guilliam.xavier@gmail.com (Guilliam Xavier) --0000000000008e292905c57e5b26 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 23, 2021 at 11:54 PM Rowan Tommins wrote: > 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 =3D 'Zoe=CC=88'; // "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) "=EF=BF=BD" > string(2) "=CC=88" > string(3) "e=CC=88" > > https://3v4l.org/IMoWQ > I thought about the same during the night! Just to complete: there's also iconv_substr() (but with the same result as mb_substr()), and here are two links to compare: https://3v4l.org/kU9D5 vs https://3v4l.org/pAvB0 Regards, --=20 Guilliam Xavier --0000000000008e292905c57e5b26--