note 85980 deleted from function.json-decode by salathe

From: Date: Mon, 21 Sep 2020 15:02:21 +0000
Subject: note 85980 deleted from function.json-decode by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215444@lists.php.net to get a copy of this message
Note Submitter: jrevillini ---- When decoding strings from the database, make sure the input was encoded with the correct charset when it was input to the database. I was using a form to create records in the DB which had a content field that was valid JSON, but it included curly apostrophes. If the page with the form did not have <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> in the head, then the data was sent to the database with the wrong encoding. Then, when json_decode tried to convert the string to an object, it failed every time.

« previous php.notes (#215444) next »