Created
April 6, 2012 12:23
-
-
Save fushihara/2319296 to your computer and use it in GitHub Desktop.
日本語が読めるjsonエンコード
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($str){ | |
//"\u3042\u3044\u3046\u3048\u304a" → "あいうえお" | |
$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