the plugin I'm currently working on has to store user inputs which might contain 4 byte unicode characters like emojis. MySQL is not able to handle this with a utf-8 charset. It works if the charset of my tables is set to utf8mb4
and if I add 'charset' => 'utf8mb4'
to config/db.php
. Since the file config/db.php
does not belong to my plugin, but to the installation of Craft itself, I'd like to not modify it.
Alternatively, I can convert the inputs with StringHelper::encodeMb4()
but then I would have to do that at every place where something from the outside enters my tables.
Is there any pragmatic way of handling this?
Greetings Jus
beforeSave
event to convert the string automatically when you do$record->save()
?