Reputation: 577
I have a strings like
$string1 = 'love is all mine 🔥';
$string2 = '🔥Sarah is good girl⭐';
$string3 = 'हिन्दी ya ⭐';
$string4 = 'hái 还/還 ("still"), yǐjīng 已经 ';
i want to encode them in a harmless encoded strings like
Api Hatal\u0131d\u0131r. L\u00fctfen kontrol ederek tekrar deneyiniz
in which no special charactor and utf8 character so that i can use it in javascript. I have tried utf8_encode()
and mb_convert_encoding( $string4 , 'UTF-8', 'UCS-2BE');
. utf8_encode()
is simply not working as it is giving error in javasciprt (because i want to create json response and to use it in my code). and mb_convert_encoding( $string4 , 'UTF-8', 'UCS-2BE');
is converting whole string into other Chinese characters.
Upvotes: 2
Views: 134
Reputation: 420
you can use iconv for converting
iconv('utf-8', 'utf-8//IGNORE',$str);
and change utf-8 encoding to anything you want. first parameter is your current text encoding and second one is which encoding you want to convert it to.function doc is ...
string iconv ( string $input_charset, string $output_charset, string $str )
Upvotes: 2