You might think that using UTF8 encoding and collation in MySQL or MariaDB would solve the character encoding issues for good. Wrong! In MySQL and MariaDB UTF8 is an alias to UTF8MB3, which means it cannot store four-byte character sequences. Whose idea was that?
So, use UTF8MB4 instead. Sigh.