Issues with PHP's serialization format
Forum /
General /
Issues with PHP's serialization format
Reply
Subscribe
Start new thread
Syndicated Feed (RSS)
|
Displaying 1 to 1 of 1
|
Previous
1
Next |
| Author |
Message |
hfuecks
Posts: 1
|
|
Issues with PHP's serialization format - Posted: December 23, 2004 - 1:08 AM
|
Quote and reply
|
Hi,
First great stuff with phpBeans. Notice you're using PHP's serialization format (as generated by serialize / unserialize).
I've used it before as well in JPSpan (http://jpspan.sf.net) but have now basically replaced it with an XML representation of a data structure, primarily because of the way strings are encoded with serialize() and multibyte characters. PHP is unaware of multibyte characters, as illustrated by this example;
echo serialize('HÃllo');
Gives;
s:8:"HÃllo";
In other words, although there's only 6 readable characters, PHP sees 8 bytes.
The problem is when you start using this format across multiple systems where different charsets are being used by default and different languages which _are_ aware of multibyte characters (e.g. Javascript where I've personally run into the problem).
Anyway - I put up some notes up here: http://jpspan.sourceforge.net/wiki/doku.php?id=php:serialization#implementations - there's also implementations in other languages listed.
In the end I'd recommend using a different format (probably XML). I wrote one for JPSpan which is roughly described here: http://jpspan.sourceforge.net/wiki/doku.php?id=encoding:jpspanxml and there's a PHP parser for it available here http://cvs.sourceforge.net/viewcvs.py/jpspan/jpspan/JPSpan/Unserializer/XML.php?view=markup - it's close enough to PHP's serialization format in it's basic structure to make it easy to replace. As you're using LGPL, feel free to re-use anything you like
|
|
Back to top
|
|
Return to Top
|