Page 1 of 1

Serialized array with strange chars

Posted: Fri Apr 19, 2013 3:23 am
by mandrake88
Hi!

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)));

Error:

[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?

Re: Serialized array with strange chars

Posted: Fri Apr 19, 2013 6:10 am
by Paul
I dont think the stripslashes should be there, as there is no addslashes in the encode line.