On several occasions I have found that I had to store and manage characters in UTF8MB4.
In fact, it has been necessary for me on these 2 occasions.
- In the example I did to collect the messages from an email account and store them in database tables. Now it is very fashionable that or in the title or content they put Emoji (little pictures) and these are usually characters that use UTF8MB4.
- I have made a plugin so that "emoji" can be included in a text area field and these "emoji" are characters in UTF8MB4, so by default, using PHPRunner, I could not save this data in the database.
Well, I have solved the problem and I want to share it with you.
- To resolve it, the recipient field of this content must be specified as having the character set of UTF8MB4.
- In the "after application initialized" event of our application we must put these 2 lines:
$sql = "SET character_set_results = 'utf8mb4', character_set_client = 'utf8mb4', character_set_connection = 'utf8mb4', character_set_database = 'utf8mb4', character_set_server = 'utf8mb4'";
DB::Exec($sql);
Greetings,
fernando