I am trying to convert this in to readable UTF8 text in PHP
Tel Aviv-Yafo (Hebrew: \u05ea\u05b5\u05bc\u05dc\u05be\u05d0\u05b8\u05d1\u05b4\u05d9\u05d1-\u05d9\u05b8\u05e4\u05d5\u05b9; Arabic: \u062a\u0644 \u0623\u0628\u064a\u0628\u200e, Tall \u02bcAb\u012bb), usually called Tel Aviv
Any ideas on how to do so?
Tried several methods online, but couldn't find one.
In this case I have unicode in Hebrew and Arabic
None of the other answers work perfectly as is. I've combined them together and my addition results in this one:
$replacedString = preg_replace("/\\\\u([0-9abcdef]{4})/", "&#x$1;", $originalString);
$unicodeString = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
This one definitely does work :)
I encountered the same problem recently, so was glad to see this question. Doing some tests, I found the following code works:
$replacedString = preg_replace("/\\\\u([0-9abcdef]{4})/", "&#x$1;", $original_string);
//$unicodeString = mb_convert_encoding($replacedString, 'UTF-8', 'HTML-ENTITIES');
The only thing I changed is that I commented out the 2nd line of code. Webpage, however, must be set to display UTF-8.
Enjoy!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With