MySQL update/insert strips backslashes for unicode entries

Issue

I’m trying to insert/update a SQL field with JSON data that encodes unicode as \u, but it’s stripping it out:

"SauteƩd -> ["Saute\u00e9d"]

However, it’s being saved in the database like this:

["Sauteu00e9d"]

I’ve tried countless preg_replace and str_replace methods, but none of them work. Is there something I can do about this – it’s driving me mad.

Thanks!

Solution

Use mysql_real_escape_string if you aren’t.

Answered By – Andre Backlund

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published