How to display emojis into php which are comes from ios encoding?

1.3k Views Asked by At

we are developing the ios application and one step we are getting stuck.

in the application screen emojis are save thorugh the api in php using ios functions NSNonLossyASCIIStringEncoding so in php there would like

Sportlich drauf \ud83d\udcaa\ud83c\udffc, bin ein gro\337er Barca fan \ud83d\udc99\u2764\ud83d\udc9b. Besch\344ftige mich viel mit Kunst, Architektur und Geschichtlicher Kunst in meinem schul Verlauf 
\ud83d\ude04. H\366r sehr gerne deutsch Rapp \ud83c\udfbc\ud83c\udfbb, lese gerne Mangans und bin absoluter anime fan \ud83d\udc4c\ud83c\udffc. Rauche und trinke kaum, ich paffe gerne eine Zigarre in sch\366nen Moment und trink nur auf events \ud83d\ude09. 

so how this converted emojis are decoded in webpage and shows as actual emojis

we are using php as server side and mysql as database. can any php library or anyother things would help then let me know.

i just want to decode that string in php and show emojis in webpage.

2

There are 2 best solutions below

1
On
$myInput = '\\ud83d\\ude01';

$myHexString = str_replace('\\u', '', $myInput);
$myBinString = hex2bin($myHexString);

print iconv("UTF-16BE", "UTF-8", $myBinString);

Happy Coding

0
On

Try this - http://code.iamcal.com/php/emoji/

You just need to download Emoji.php and covert unicodes to emojis.

require_once('Emoji.php');

$text='Sportlich drauf \ud83d\udcaa\ud83c\udffc,Barca fan \ud83d\udc99\u2764\ud83d\udc9b \ud83d\ude09.';

echo Emoji::Decode($text);