Removing emojis from variable

后端 未结 3 1205
天命终不由人
天命终不由人 2021-02-04 20:36

I\'m using Smarty to pass in and display the contents of a first_name variable. Some users have Emoji characters (http://en.wikipedia.org/wiki/Emoji) in their

3条回答
  •  野性不改
    2021-02-04 21:16

    I tried some of the solutions posted above, but no one worked, however, when I converted the string to UTF-8 using the mb_ function it works properly.

    You can use:

    trim( preg_replace('/[\x00-\x1F\x80-\xFF]/', '', 
          mb_convert_encoding( $emojiString, "UTF-8" ) ) );
    

    Works for me.

提交回复
热议问题