Re: Re: [PHP-DEV] [RFC] Remove \0 from default trim() character mask

From: Date: Wed, 25 Mar 2026 15:38:05 +0000
Subject: Re: Re: [PHP-DEV] [RFC] Remove \0 from default trim() character mask
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-130453@lists.php.net to get a copy of this message
On 25 March 2026 08:23:38 GMT, Robert Humphries <contact@developer-rob.co.uk> wrote: >I think it would be useful if there were some examples of when you >would want to be using trim but _not_ trim NULL bytes. The >examples >in the RFC currently show the expected change in behaviour; which is >good - but you could also achieve the same effect by not running >trim in the first place, as the only character in the examples >that >is expected to be removed before or after the change is the NULL byte >(even in the example with a new line followed by null bytes, after the >change then the string would be identical to before the trim). I second this request, and would go further: the examples should show a situation where you *do* want to trim other "unusual" characters like "\v" and "\f". The RFC talks about corrupting binary data, but wouldn't trimming *any* bytes from that data cause corruption? If you know the data is padded by a *specific* character, then passing that character to trim() explicitly is the *only* safe way to use it. PS: Please can everyone remember to start your reply *below* the text you're replying to, and *trim* parts that are not directly relevant. Rowan Tommins [IMSoP]

« previous php.internals (#130453) next »