I have a web app I built using Laravel 5.2 , my question is how do I store then show emoji's. At the moment when I use an emoji from my iPhone , fire for instance, after saving the database returns ???? . Ive set the 'charset' = 'utf8mb4'; 'collation' = 'utf8mb4_unicode_ci'
but still get the same result. Do i need to install a package or something?
Some emojis such as ⚡ can be stored in MySQL's 3-byte utf8 encoding, but others such as face screaming in fear cannot.
Use urlEncoder to encode your String having emoticons. Store it in DB without altering the MysqlDB. You can store it in solr core(decoded form)if you want or you can store encoded form.
Make sure you have the charset and collation correctly setup in the database config file as well, to ensure Laravel actually knows what charset to use when saving:
// config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With