Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129700 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 lists.php.net (Postfix) with ESMTPS id D2EDB1A00BC for ; Sat, 27 Dec 2025 18:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1766859480; bh=1Wbqo0uhwoD6Q5jv8SF33rrBBFn3BDIZe8+5U7JGteM=; h=References:In-Reply-To:From:Date:Subject:To:From; b=TeeJXyOTpJwfHtsN+oHP9fDM/33Fnc27RAbtfmL5utSbgmFRQa3itc7kkZw0qQT76 n7NGelHIAA9VB3wiyE/xfxY5DipIicuJDNUr485icXLLGlEdgbJsFTp0TlYl8EqoWz xU0BR48E9JgEM8gnU24LGsIaXR+LSRhrwKRozDl6Imbk3RlWgni5BgLCzZUwJHYtSy ElmxYxPwyZrmV2zkDdZSPWFqyFkKcU0O+LbiVWgFNmvyp/Ho0RWWjAU++25QlS7Cd4 MxnaceRIQzPsME6WNr6ropWL86DCLgpLhSPkchGfxsNH3Py0jpS8fRQyABPJm3+3JO P+E6Qrdy/hFNQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 52F42180041 for ; Sat, 27 Dec 2025 18:17:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,HTML_MESSAGE, HTTPS_HTTP_MISMATCH,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-yx1-f44.google.com (mail-yx1-f44.google.com [74.125.224.44]) (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 ; Sat, 27 Dec 2025 18:17:58 +0000 (UTC) Received: by mail-yx1-f44.google.com with SMTP id 956f58d0204a3-6446d7a8eadso6585136d50.0 for ; Sat, 27 Dec 2025 10:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benramsey.com; s=google; t=1766859473; x=1767464273; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=knK3z3hkWIY3ZdyXUrZAC+GsTyglXta5mnvBWyiqMpY=; b=ezHINLvevKfoCFH9cNLfeVYGTIhoWDqCEXxgVhOmtUITTfrSyVBBNwI9uIunhH7/oZ Zo1W6eqOlb+K+4/y4DSxUN17ZD6/daqlR5bNBCMHlWxm5ye35xPlOkQpMPx65vWcgYc+ XOW9zuvdiexYGm4Xq9QsLoOdO1/OBGiXvs+TFEqDHKj30pWlMAg7ELi22ZKFkmJLxej7 3P8uvR9b34rpwVQDkmObzTIV95fVn41eXIUnb6YvCI29eidAtb1ElwOm3iogBTP/7zxb /vZt+KqIC6vbMhoRjV++9QJG2w0MEflOw1J9rd98oq6AFjktgfM6xrVpFV6wgZPqqiJ5 xIOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766859473; x=1767464273; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=knK3z3hkWIY3ZdyXUrZAC+GsTyglXta5mnvBWyiqMpY=; b=oYWawTP0yH7KBshNEw/X+4LBoK5soFoJj9559LLhZHOgDtDwpDctxLSDJDhneGH8th mlig+j8Rya902qS+tKA4VYW5PouH1HBOFEqfET4wLLnp8NxUNXzA3525dgiuqDtzZRAr eLCdTZdjYnwEnH5JpsQ9KNlHJO8+uU1X5us2Y77KUbA1LfsE0lGwkmGPQ3oRpVTNOauM /EJ505diPnB/4/Xb54pfII9O/oAul+IrW+o+r8vuXNMtkn9s1QhzfjrydxAn3eXbl/7k 4tcinTGaICfwxj6WcU0uqYpLCTbjL4sBl7d1TgCLOAfodAOWjGr92HhOqBefPW8QzGIY OU/Q== X-Gm-Message-State: AOJu0Yww6+0/lGS11eGMreYCenAjN4qYftIW8dQjT5poBBr3PGx/Nr3m QbjYXH/1AKETWBv2c2e3QUpujGtbLw3uV2+J9c+Hog6yjW8gvjWFFBad2FDOQtR8e3e8uil8Bep cERsFR3zPWxmLL4vwYsxHP72HvIe4kSIk73hkagLStC6Ad92zH8Y= X-Gm-Gg: AY/fxX4qx2uk0kZHvNHaBNIZN2ZzbmEhSjUEFlo/EDCtVeYmZLABkpfLO73MWb4eSAx DbKiDcGwAZ8981NWf2Lxym7CX/EssigQLKE0vouet0c+T2sxHHcRx6aoGkfNLcYd4e1OUOQv7D5 hNS9NQUImDJLcycXu7qeP/Qx00OQnF7hFbVLt+MMoaIG5Mcw23GWqxGoiKsalQlRnJW/vRYIhaU CXVVo7yJsBeJb5wQ0hKidWZ9sJslWhQYU9nHVQKrOwXOZhIzyl+LgB0V5KO4n4j5hjL19/dtil2 hbTFHw== X-Google-Smtp-Source: AGHT+IHUufHOO/AT+/hgXhKussTvDZwcDWxJ+odp3GZ23yocMFkHEG9FoNhTaO5tmWFZ8lvsjCQtB4WojpmZVL3IEVw= X-Received: by 2002:a05:690e:12cb:b0:641:f5bc:69a2 with SMTP id 956f58d0204a3-6466a8c7cbemr19168273d50.80.1766859472542; Sat, 27 Dec 2025 10:17:52 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <701b7ec.277f.19b5f634c4d.Coremail.lamentxu@163.com> In-Reply-To: <701b7ec.277f.19b5f634c4d.Coremail.lamentxu@163.com> Date: Sat, 27 Dec 2025 12:17:41 -0600 X-Gm-Features: AQt7F2ovvxzDRn8sLzMIlAfU35IiucgDCjR6SlVxZeCZeqvR3tdihFYe6GeU_7Q Message-ID: Subject: Re: [PHP-DEV] Add form feed as a whitespace character in trim, ltrim and rtrim To: PHP Development Content-Type: multipart/alternative; boundary="0000000000003aaceb0646f307df" From: ben@benramsey.com (Ben Ramsey) --0000000000003aaceb0646f307df Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 27, 2025 at 04:40 LamentXU wrote: > Hi Internals, > > I have opened a Pull Request to add \f (form feed) to the list of > characters stripped by default in trim(), ltrim(), and rtrim(). > > Currently, the default behavior of trim() strips the following characters= : > \n, \r, \t, \v, \0, and space. The form feed character \f is notably > missing, despite being widely recognized as a whitespace character (in > python, rust...). > Although I think this change aligns trim() with standard whitespace > definitions, it is technically a backward compatibility break. I am writi= ng > to check if there are any strong objections to this change or if it > requires further discussion. > > References*:* > > - > > Issue: *https://github.com/php/php-src/issues/20783 > * > - > > Pull Request: *https://github.com/php/php-src/pull/20788 > * > > Thanks, > Weilin Du > Notably, `mb_trim()`, introduced in 8.4, includes `\f` in the list of characters it trims. https://www.php.net/mb_trim I=E2=80=99m not opposed to this change, but the BC break could lead to real= ly difficult and tricky bugs in applications that rely on the form feed to be retained. I can=E2=80=99t think of any use cases that would expect form fee= d to remain after trimming, but there might be some. On the other hand, many users might consider it a bug that form feed isn=E2= =80=99t trimmed, so this might be argued as a bug fix, especially since other languages consider form feed as a whitespace character to remove in similar situations. I=E2=80=99m for this change, but on the fence about the BC break. Cheers, Ben --0000000000003aaceb0646f307df Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Dec 27, 2025 at 04:40 LamentXU <lamentxu@163.com> wrote:

Hi= Internals,

I have opened a Pull Request= to add=C2=A0\f=C2=A0(form feed) to the list o= f characters stripped by default in=C2=A0trim(),=C2=A0ltrim(), and=C2=A0rtrim().

Currently, the default= behavior of=C2=A0trim()=C2=A0strips the follo= wing characters:=C2=A0<= /span>\n,=C2=A0\r,=C2=A0= \t,=C2=A0\v,=C2= =A0\0, and space. The f= orm feed character=C2= =A0\f=C2=A0is notably m= issing, despite being widely recognized as a whitespace character (in pytho= n, rust...).

Although I think this change aligns=C2=A0trim(= )=C2=A0with standard whitespace definitions, it is technically a bac= kward compatibility break. I am writing to check if there are any strong ob= jections to this change or if it requires further discussion.

References:

Thanks,
Weilin Du


Notably, `mb_trim()`, introduced in 8.4, includes `\f` in the list of char= acters it trims.=C2=A0

= I=E2=80=99m not opposed to this change, but the BC break could lead to real= ly difficult and tricky bugs in applications that rely on the form feed to = be retained. I can=E2=80=99t think of any use cases that would expect form = feed to remain after trimming, but there might be some.

On the other hand, many users might conside= r it a bug that form feed isn=E2=80=99t trimmed, so this might be argued as= a bug fix, especially since other languages consider form feed as a whites= pace character to remove in similar situations.

=
I=E2=80=99m for this change, but on the fence about= the BC break.

Cheers,
Ben

--0000000000003aaceb0646f307df--