PHP 6 Unicode Breaks Datpack

Written on October 12, 2008 by Mike Gerwitz

Well, it seems that PHP 6’s unicode support breaks the datapack. So I’ll have to spend some time getting it to work properly (mostly a tedious task of using binary strings rather than the default unicode). This does mean, however, that in order for the project to be backwards-compatible, PHP 5.2.1 is required (that is when the binary cast was added). However, I will provide a tool to remove all the casts from all files to support 5.1 as before. Eventually.

Unicode support definatly complicates the project a great deal. Let’s just hope PHP 6 doesn’t change too much before it’s release. I’d hate to do all this work for nothing. But it’s a chance I’ll have to take - I can’t put off PHP 6 support until the last minute. That’d be hell to fix.

Edit: Well, I had almost given up due to a bug in fread() in PHP 6. When reading past the EOF, it returns FALSE, rather than an empty string, as it does in PHP 5. After a fair deal of research and experimenting (when I upload my notes you can see my shameful thought process) I managed to identify it and provide an alternative (and perhaps speedier) solution.

The datapack wrapper didn’t take much work at all - just a few binary casts here and there. Not the bunch I expected. The reason for it is simply because - it’s a wrapper. Users calling fwrite() and such can deal with the casts - they have to, or PHP bitches at them. I’m not saying the datapack is entirely ready and prepared - it’s not. I haven’t even tested it yet with unicode strings. But it does work as originally intended. I’ll worry about the details later.

Anyway, I’ll commit the changes after I fix up a few things - primarily add the new exceptions I’ve been too lazy to add. I also changed the convert function around a little - instead of accepting a $new_file argument, it simple generates it own, deletes the old file for you, and renames the new, converted pack, to the old filename.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>