Last active
May 5, 2021 11:09
-
-
Save MahdiMajidzadeh/88407f4c33a294cae29ed1493332d7c0 to your computer and use it in GitHub Desktop.
Fix JSON Persian character in php
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
// in php >= 5.4 | |
echo json_encode($myarr,JSON_UNESCAPED_UNICODE); | |
// in php <= 5.3 | |
header('Content-Type: application/json; charset=utf-8'); | |
function jsonRemoveUnicodeSequences($array) { | |
return preg_replace("/\\\\\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($array)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great, thanks.