Created
April 26, 2012 05:42
-
-
Save fushihara/2496307 to your computer and use it in GitHub Desktop.
マルチバイト文字がそのままのjson_encode ref: http://qiita.com/items/71e1ec7e52b76f467d29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function json_jap($obj){ | |
$str=json_encode($obj); | |
$str=preg_replace_callback('{\\\\u([0-9a-f]{4})}',function($m){return mb_convert_encoding(hex2bin($m[1]),'UTF-8','UTF-16');},$str); | |
$str=str_replace(['\/','>','<',''','&'],['/','>','<','\'','&'],$str); | |
return $str; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment