Serialized array with strange chars

Discussion forum for MOD Writers regarding MOD Development.
Registered User
Posts: 91
Joined: Tue Jun 03, 2008 3:21 pm

Serialized array with strange chars

Post by mandrake88 »


I have an array that contains strings that can be in many languages, and have REALLY strange chars (result of parsing the data from files that may have chinese chars, the result can be very weird).
In order to prevent errros during sql inserts, i'm using the following line:

$foo = utf8_encode(utf8_normalize_nfc(serialize($data)));

But when i fetch the data from the DB, can't apply unserialize

$retrive_foo = unserialize(stripcslashes(utf8_decode($data)));


[phpBB Debug] PHP Notice: in file [ROOT]/includes/functions_foo.php on line 290: unserialize(): Error at offset 853 of 1356 bytes
[phpBB Debug] PHP Notice: in file [ROOT]/includes/functions_foo.php on line 291: unserialize(): Error at offset 1112 of 4851 bytes

Some ideas of how handle this?

Infrastructure Team Leader
Infrastructure Team Leader
Posts: 25658
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier

Re: Serialized array with strange chars

Post by Paul »

I dont think the stripslashes should be there, as there is no addslashes in the encode line.
Knock knock
Race condition
Who's there?

My BlogMy Photosmy phpBB Extensionscustom phpBB work & Development


Return to “[3.0.x] MOD Writers Discussion”