0

I am trying to convert Unicode character to text in PHP. But the string is the mixture of Unicode characters and text. But it is not working.

I followed this link (Unicode character in PHP string)

<?php

   $unicodeChar = "{'singer': u'', 'name': u'\\\\u101c\\\\u1031\\\\u1011\\\\u1032\\\\u101c\\\\u103d\\\\u103e\\\\u1004\\\\u1037\\\\u103a\\\\u101c\\\\u102d\\\\u102f\\\\u1000\\\\u103a'}\\r\\n\\r\\n    artist          : Thar Gyi\\r\\n    album           : Sal Pone Ta Pone\\r\\n    genre           : R&B\\r\\n    copyright       : MyanmarSongs.NET\\r\\n    track           : 1\\r\\n    title           : Lay Htal Hlwint Lite";
   echo json_decode('"'.$unicodeChar.'"');
   echo mb_convert_encoding($unicodeChar, 'UTF-8', 'HTML-ENTITIES'); 
   echo mb_convert_encoding($unicodeChar, 'UTF-8', 'UTF-16BE'); showing nothing

?>

All the above scenarios are not working when the value is the mixtures of Unicode characters and text like I used. But it is working when the value is so simple like this:

$unicodeChar = '\u1000';
echo json_decode('"'.$unicodeChar.'"');

How can I achieve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372

1 Answers1

0

use following code

$unicodeChar = '\u1000';
echo json_decode('"'.$unicodeChar.'"');
Rajveer gangwar
  • 715
  • 4
  • 14