Re: Why are serialized strings wrapped in double quotes? (s:<len>:"<string>")

From: Date: Fri, 09 Feb 2024 17:39:00 +0000
Subject: Re: Why are serialized strings wrapped in double quotes? (s:<len>:"<string>")
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-122355@lists.php.net to get a copy of this message
On Tue, Feb 6, 2024, at 21:19, Sanford Whiteman wrote: > I'd like a little background on something we've long accepted: why > does the serialization format need double quotes around a string, even > though the byte length is explicit? > Instead we need to be aware of the leading and trailing " in our state > machine but I'm not sure what the advantage is. Dunno why, but is has made my life much easier. I've seen many situation where serialized data was converted from CP1252 to UTF8. Then the string length changes and unserialization leads to an error condition. Without the quotes possibly many cases would go undetected. > Was this just to make strings look more 'stringy', even though the > format isn't meant to be human-readable? In my mind the format is a nice pragmatic middle between reasonably efficient, reasonably robust, too feature-complete (too many allowed_classes) and somewhat human readable. At least enough for incidental debugging or manual tinkering.

« previous php.internals (#122355) next »