Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115080 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 84610 invoked from network); 23 Jun 2021 21:36:03 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Jun 2021 21:36:03 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B7F0C1804DA for ; Wed, 23 Jun 2021 14:54:38 -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,NICE_REPLY_A, 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-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 ; Wed, 23 Jun 2021 14:54:38 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id a13so4256169wrf.10 for ; Wed, 23 Jun 2021 14:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=/Tpy7/PrxGmu4F4NeerTGWO/mt0l7F4I8GdVTHrytmc=; b=Pyl7u9N/9Fb0a5YkmW2mpkcXWDKzFgVhKN0+9oEFNXbbnF+u2iCkgEDZonysCU9g+2 FwrndWviY9gN7z/i+E+Nx5253ASwqMJ6z5lQGq57XFNQYD3VuqYU7zsGYXfyh3/PsWA9 f2ES/P48mWG572hJRCSrEvtFn1WoLaMj6dVWciSkXj1DOEV4WMEFc8Md/zhwKUouYQPQ gyOMmf6Kaj+KqtaeELE1XfuaqxsiWqJraMmJouZp1vE7SU7Odn94Tv3B76uKA6Vwttxy f1TbwdwW17S+uHsrhPzNLE/rYYxzmVkGRCjKP6HkviArO5wjGqLd6tkSBtRMTXXy02Sf qFFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=/Tpy7/PrxGmu4F4NeerTGWO/mt0l7F4I8GdVTHrytmc=; b=cDQPMrJnxh6pOX4qx8DeC/91dpRb1uLMESk12xCzvdoViLd5nd2B0t4yPsA1NXJ1ru tUZ/H9V1OVx6NsmCwTLS5yEGOr3rzV6S0v/L2gABSSFaJ2SP5sRaKif0bn4hAw12uPWX H501TCpWlPh6wDxk7NAdoDXw3+7TuAIMnte6rRKA+27QG9s23kNhTN9J67ayZGHD5c51 Y3zCH96V9X0M1cBU+mLIYCPrYsHZgyrm8yhXz8K7K94Kl43ZK1x9K+7jBiBZa2fM3G2s 5xeaI6JanmZ6XHDKVqYENeny/DTp+kzR9efbCCZLq/YlQlhzRq30BcTwoRY5VexUzDrN 1Z0Q== X-Gm-Message-State: AOAM5333B4ZiRYKN0ANuXFlOJ+VAtJXUlXVsg0jxh6e+bO8ocULsmyz+ JgO1gFUB5vhOAP4uYRwC95RDBYzSjrE= X-Google-Smtp-Source: ABdhPJwK52FinZ8wP4PvUfD6z1IjiijedGZ/HB72rWSKjdp1S+oF1buDVRjLvS42xxdzJ/jOIvkFuA== X-Received: by 2002:a5d:66c6:: with SMTP id k6mr290635wrw.422.1624485273080; Wed, 23 Jun 2021 14:54:33 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id p15sm975912wmq.43.2021.06.23.14.54.32 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Jun 2021 14:54:32 -0700 (PDT) To: internals@lists.php.net References: <012901d7683a$446a7ba0$cd3f72e0$@gmail.com> <7e2b946f-c302-5350-a6e6-1e06802c95a5@gmx.de> Message-ID: <5bbec9d0-aeb8-9ff7-fdf1-4c38d78cb624@gmail.com> Date: Wed, 23 Jun 2021 22:54:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <7e2b946f-c302-5350-a6e6-1e06802c95a5@gmx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Introduce str_left/right In 8.1 From: rowan.collins@gmail.com (Rowan Tommins) 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]