Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122561 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 6C4691ADA75 for ; Tue, 5 Mar 2024 07:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1709623573; bh=jAw9lptYhp+5e3tBOm+RxB8jofvbKmPHrSWPV/OHfA4=; h=References:In-Reply-To:From:Date:Subject:To:From; b=SYT9vp8dDmTn5e6SPPuWW/fRmqfBkORJAmN16RpRLMkOdPWBYZW7pyKdctX7dnxdg N5TeSOEq8CHWlJ0dId/K9+J4WfxCqf+MShjaNEA0fGtWhBebyxa5ytjAd5xagwhbUy ZRVUk9FD9Gr0R/qmIht0X4uG3HA5Z6CYQp4nLeFbiY5sUDd7ZyNcCn/NsSoWWVB+3g 9yFHB9/qDWobP8XTcTE2cs4X0+ps74tz/A2Lhm1V41cXdtGVtk5KdG33Cj2A6TOffv vJOvfAJy6PMmuNBy3sOSc+icCh1TemmHOuog9ieVo88tQfoUCTTytqBZZdJbJCVJdz UpF8xlivNmkoA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EB087180072 for ; Tue, 5 Mar 2024 07:26:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 5 Mar 2024 07:26:08 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-412e4426e32so12202145e9.2 for ; Mon, 04 Mar 2024 23:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709623555; x=1710228355; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jAw9lptYhp+5e3tBOm+RxB8jofvbKmPHrSWPV/OHfA4=; b=QGluj7ITfx4GCU/Y6m5pOsheGU8gxy63+g8CufapSPSDW5mVdAUfcE/v+Q9FrXVEiv tJhgqGFl+EEqpfrCJpdi7RIriX+TuJZjJKM5s3W1Pa6y039lF5ysWyVn7edp444qEx9n DvR9hYLT7UfG6CHr3qvblIE1dO4K1et56G1MqLrtjJgpVXADEyyJOcb1lnwH6n6y8fVj +0qkYpCS3gEQOKM84kvkE9SR2GqvjAcDu5nY0SUxL1TqjWUHxe9PY47COh8jG6YJPExP RAWMq7Wl578ac7+4ppZ7cVUSmriX66YKXqZwaq5Pzc1hLlUppDU8fC6F5pqTZoVBapuN ALqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709623555; x=1710228355; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jAw9lptYhp+5e3tBOm+RxB8jofvbKmPHrSWPV/OHfA4=; b=vZgE87pmg5HgdrZswS6P6y/an60vsV5/YCl+rAY3UTnan8QXOXNY/1RZczjGXT8n6g vGTWdj/vlQ0yWw9CrVpv7+W9kvJX8QyUh8WYgC3KYOAwoojrpLprTTRzC/ByY/K5vSfk dhBvTkPgOz57EGiTiuwr6S6+QGx1SBQXB5pLjwXtaurx5Z0v7pUCaygIK3zUg8tuD/dU lYe51/bKlrqZEu8dWHyEbsvLBprCxsZZWv5PGtyN4lZ/0MMqkxawOUudr2zpA0fnR7oV qpjYCByP4FpNIZXh+rx0Ye6ElCrmiHByypMHVrNytrgx+hpi0TJlK8BnWIjnkjHXcQXF HhYQ== X-Gm-Message-State: AOJu0Yzwd7oBJvI4QFWMUqsil2y3ftNK31JaFj33MB9nqypHL25zQYVD ibhnHhzMi/SfF8OUnCnp2GZNaH5QnD4PtZ8IxpGdMTSXiLAslYY+u8qT4f/uGrPY0C/h3i1gP9K CQIS78sYO7VfKqdMheLL5BYmTpaXXyQe89UVE X-Google-Smtp-Source: AGHT+IESFaguxTfk05vrPdcv05XsKtvONlurDSd65+m9+A66GR3u30WrXo6Mg/duNmLCU2trvzUPDf04wmy3YDvinf4= X-Received: by 2002:adf:e0c1:0:b0:33d:c572:7641 with SMTP id m1-20020adfe0c1000000b0033dc5727641mr10175461wri.14.1709623554678; Mon, 04 Mar 2024 23:25:54 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 5 Mar 2024 16:25:43 +0900 Message-ID: Subject: Re: [PHP-DEV] [Discussion] grapheme cluster for str_split function To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: youkidearitai@gmail.com (youkidearitai) 2024=E5=B9=B43=E6=9C=885=E6=97=A5(=E7=81=AB) 5:52 Niels Dossche : > > Hi Yuya > > This sounds useful. > > I do have a question about the function signature: > function grapheme_str_split(string $string, int $length =3D 1): array {} > > This always returns an array. > However, looking at your PR it seems you return NULL on failure, but the = return type in the signature isn't nullable. > Also, from a quick look, it seems other functions return false instead of= null on failure. So perhaps the return type should be array|false. > > What do you think? :) > > Kind regards > Niels > > On 03/03/2024 00:21, youkidearitai wrote: > > Hi, Internals > > > > I noticed PHP does not have grapheme cluster for str_split function., > > Until now, you had to use the PCRE function's \X. > > > > Therefore, I try create `grapheme_str_split` function. > > https://github.com/php/php-src/pull/13580 > > It is possible to convert array per emoji and variation selectors using= ICU. > > > > If it's fine, I'll create an RFC. > > > > Regards > > Yuya > > Hi, Niels Thank you for your comment. Indeed, returns false is make sense. Therefore, I changed to returns false when invalid UTF-8 strings. Regards Yuya --=20 --------------------------- Yuya Hamada (tekimen) - https://tekitoh-memdhoi.info - https://github.com/youkidearitai -----------------------------