-1

i have problem with print currency symbol in php when i print currency symbol using echo function i got wrong output

i try this code i have array like

'Turkey New Lira - TRY' => 'も'
$key = $row['Currency']; $value = $array_currency[$key]; echo $value;

i have this code for print

$key = $row['Currency']; $value = $array_currency[$key]; echo $value;

i get output like

ã‚‚

alse have problem with echo json_encode get output like

\u3082

give me right solution for this

Trushar Narodia
  • 3,511
  • 2
  • 11
  • 17
  • 2
    Make sure you are using the correct `meta` headers in your page - with utf-8 that symbol displays correctly ... `` – Professor Abronsius Feb 10 '16 at 09:24
  • buddy i have problem with json_encode echo – Trushar Narodia Feb 10 '16 at 09:43
  • Turkish Lira are written using the Japanese "mo"...!? – deceze Feb 10 '16 at 09:43
  • 1
    [Handling Unicode Front To Back In A Web App](http://kunststube.net/frontback/), [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/) – deceze Feb 10 '16 at 09:44
  • [Reference: Why are my “special” Unicode characters encoded weird using json_encode?](http://stackoverflow.com/q/22745662/476) – deceze Feb 10 '16 at 10:11

1 Answers1

0

Add the meta tag to your html

<meta http-equiv="content-type" content="text/html;charset=utf-8" />

For json_encode

$string="も";
echo $string."<br/>";
echo "Encoding: " . mb_detect_encoding($string) . "<br/>";
$encoded = json_encode($string);
echo "Encoded val: $encoded <br/>";    
$encoded2 = json_encode($string, JSON_UNESCAPED_UNICODE);
echo "Encoded val(with param): $encoded2 <br/>";
$decoded = json_decode($encoded);
echo "Decoded val: $decoded <br/>";

ouput

も
Encoding: UTF-8
Encoded val: "\u3082" 
Encoded val(with param): "も" 
Decoded val: も
Santhy K
  • 829
  • 1
  • 7
  • 12