Serialized array with strange chars

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

Serialized array with strange chars

Post by mandrake88 » Fri Apr 19, 2013 3:23 am

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?

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

Re: Serialized array with strange chars

Post by Paul » Fri Apr 19, 2013 6:10 am

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

Locked

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