php - Removing unicode from string -


i have following php string:

\ud83c\udf38owner ig: deidarasss\n\ud83c\udf38free ongkir banda aceh dan lhokseumawe\n\u27a1 testimoni: #testydfs\n\ud83d\udcf1line: darafitris\nsold=delete\nclose  \ud83d\ude0d\ud83d\ude03 

i wanted strip out unicode string, how can so?

i have tried following:

 private static function removeemoji($text) {         $clean_text = "";          // match emoticons         $regexemoticons = '/[\x{1f600}-\x{1f64f}]/u';         $clean_text = preg_replace($regexemoticons, '', $text);          // match miscellaneous symbols , pictographs         $regexsymbols = '/[\x{1f300}-\x{1f5ff}]/u';         $clean_text = preg_replace($regexsymbols, '', $clean_text);          // match transport , map symbols         $regextransport = '/[\x{1f680}-\x{1f6ff}]/u';         $clean_text = preg_replace($regextransport, '', $clean_text);          // match miscellaneous symbols         $regexmisc = '/[\x{2600}-\x{26ff}]/u';         $clean_text = preg_replace($regexmisc, '', $clean_text);          // match dingbats         $regexdingbats = '/[\x{2700}-\x{27bf}]/u';         $clean_text = preg_replace($regexdingbats, '', $clean_text);          return $clean_text;     } 

but doesn't help

to remove occurrences of \u.... string $text, follows:

$text = preg_replace('/\\\\u[0-9a-f]{4}/i', '', $text); 

this uses regular expression find these occurrences , replace of them empty string.

alternatively, replace occurrences of \u.... characters represent, do:

$text = json_decode('"' . str_replace('"', '\"', $text) . '"'); 

this wraps text in double quotes, escaping double quotes within, makes valid json string. \u valid json escape code, suffices decode json actual characters.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -