I'm trying to save a json_encoded strings to the database but whenever i do i get this:
u30abu30bf
when saving:
カタ
how do i decode such a thing?
tried php utf8_decode and encode but i doesn't seem to work, i also tried reading the threads below:
PHP decoding and encoding json with unicode characters
difficulty passing Japanese characters(UTF-8) via json_encode
here is a var_dump data of $flex_encoded before passing it as a parameter:
//this one seems to passing the right encoding
[{"japanese_name":"\u30ca\u30ab\u30cd"},{"japanese_name":"\u30ca\u30ab\u30cd"}]
here is the function call:
$this->updateFlexData($game_id, $flex_encoded);
here is the function for updating my db:
function updateFlexData($game_id, $json_data)
{
$arrVal = array(
'json_data'=> $json_data,
);
Db::getInstance()->autoExecute('japanese_names', $arrVal, 'UPDATE', " game_id = '".$game_id."'", false);
}
database column type is:
`json_data` longtext CHARACTER SET utf8 COLLATE utf8_bin NOT NULL
my PHP version:
PHP Version 5.3.10
Try JSON_UNESCAPED_UNICODE
json_encode($data, JSON_UNESCAPED_UNICODE);
And instead of this \u7537\u6027\u304c\u5f7c\u5973\u306b\u7740\u3066\...
you're going to get 男性が彼...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With