我正在尝试将json_encoded字符串保存到数据库,但每当我这样做时,我得到这个:
u30abu30bf
保存时:
カタ
我怎么解码这样的东西?
试过php utf8_decode和编码,但我似乎没有工作,我也尝试阅读下面的线程:
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版本5.3.10
2 回答
试试JSON_UNESCAPED_UNICODE
而不是这个
\u7537\u6027\u304c\u5f7c\u5973\u306b\u7740\u3066\...
你将得到男性が彼...
经过几个小时修改代码后,我以某种方式使它工作:好吧,它可能不是解决方案,但是: