JSON_UNESCAPED_UNICODE was added in PHP 5.4 so it looks like you need upgrade your version of PHP to take advantage of it.
(You could simply use utf8_encode, but this will only support characters that are part of ISO 8859-1).įinally, as another answer noted, you do need to make sure that you're declaring the proper charset, with an HTTP header or otherwise (of course, this particular issue might have just been an artifact of the environment where you did your print_r testing). There's also the possibility that the data currently stored in the database is in the wrong encoding.
The PHP manual indicates you'd do this by appending options='-client_encoding=UTF8' to the connection string.
php jsonencode encoding numbers as strings. This function accepts the following set of arguments. So, it seems like you need to configure your connection to Postgres so that it will give you UTF-8 strings. In PHP, jsonencode() is used to convert PHP-supported data type into JSON formatted string to be returned as a result of JSON encode operation. PHP will use the \uXXXX escaping, but as you noted, this is valid JSON.
The following constants can be combined to form options for jsonencode (). The PHP manual indicates you'd do this by appending options='-client_encoding=UTF8' to the connection string. This option can be added automatically by calling jsondecode () with the second parameter equal to true. To review, open the file in an editor that reveals hidden Unicode characters. So, it seems like you need to configure your connection to Postgres so that it will give you UTF-8 strings. Takes a JSON encoded string and converts it into a PHP variable. jsondecode.php This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. ( html_entity_decode, confusingly, defaults to UTF-8, so your method had the effect of converting from ISO 8859-1 to UTF-8.)