Created
July 23, 2014 08:29
-
-
Save Anye/22055ddd55494d48d504 to your computer and use it in GitHub Desktop.
json_encode 显示中文
This file contains hidden or 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
function __json_encode( $obj ) | |
{ | |
if( defined( 'JSON_UNESCAPED_UNICODE' ) ){ // >= php 5.4 | |
return json_encode( $obj, JSON_UNESCAPED_UNICODE ); | |
} else { | |
return preg_replace( "/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode( $obj ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment