0

I would like to encode smileys in PHP.

For example :

$string = "blah blah  blah";
mb_convert_encoding($string, "HTML-ENTITIES", "UTF-8");

I'm getting :

blah blah 😋 blah

But I would like :

blah blah 😋 blah

How I can achieve that in PHP ?

Thank you !

Manu
  • 838
  • 5
  • 7
  • 1
    I think it would be good if you said what do you want to encode them to and why. – Dharman Apr 15 '20 at 19:14
  • What's the difference? Same number of bytes, same result. – Sammitch Apr 15 '20 at 19:17
  • I'm trying to compare a string sent from a form to the same string stored in a mysql database. I'm trying to encode the string from the form to match the one in database, but I'm having a hard time with the smileys – Manu Apr 15 '20 at 19:17
  • Why are you storing HTML entities in the database? This is starting to look like an XY problem. – Dharman Apr 15 '20 at 19:19
  • It's what's Wordpress or Buddypress is doing automatically – Manu Apr 15 '20 at 19:20
  • The linked question explains how to do this, but I am really curious why would anyone ever need this. Why does Wordpress do that? – Dharman Apr 15 '20 at 19:31
  • Don't know too why is storred like that.. thank you for the link it's look like it's ok :) – Manu Apr 15 '20 at 19:34
  • I think I need to also check that in detail : https://developer.wordpress.org/reference/functions/wp_encode_emoji/ – Manu Apr 15 '20 at 19:39

0 Answers0