0
<?php 
$unicodeChar = '\u0939';
echo json_decode('"'.$unicodeChar.'"');
?>

prints : ह

expected : ह

unicode '\u0939' decoding to original character using json.

Sahil Gulati
  • 15,028
  • 4
  • 24
  • 42
jfeu1204
  • 1
  • 1
  • 1
    Possible duplicate of [How to set UTF-8 encoding for a PHP file](http://stackoverflow.com/questions/5056646/how-to-set-utf-8-encoding-for-a-php-file) – pringi Apr 21 '17 at 09:02

1 Answers1

1

Set character encoding to UTF-8 for displaying Hindi characters.

Try this code snippet here

Here we are initiating a header which will set charset for displaying the content in hindi charset.

<?php
ini_set('display_errors', 1);
header('Content-type: text/plain; charset=UTF-8');
$unicodeChar = '\u0939';
echo json_decode('"'.$unicodeChar.'"');

Solution 2:

Try this code snippet here

Here we are setting default charset to UTF-8 using ini_set.

<?php
ini_set('display_errors', 1);
ini_set('default_charset', 'utf-8');

$unicodeChar = '\u0939';
echo json_decode('"'.$unicodeChar.'"');
Sahil Gulati
  • 15,028
  • 4
  • 24
  • 42