Q:

Unicode characters emoticons in MySQL with 4 bytes

I have to insert in Mysql Strings that may contain characters like '' . I tried this:
ALTER TABLE `table_name`
DEFAULT CHARACTER SET utf8mb4,
MODIFY `colname` VARCHAR(200)
CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL;

and when I insert '';
INSERT INTO `table_name` (`col_name`) VALUES ('');

I get the following
SELECT * FROM `table_name`;

????

How can I do to get the correct value in the select statements?
Thanks a lot.

A:

You will need to set the connection encoding to utf8mb4 as well. It depends on how you connect to MySQL how  to do this. SET NAMES utf8mb4 is the API-independent SQL query to do so.
What MySQL calls utf8 is a dumbed down subset of actual UTF-8, covering only the BMP (characters 0000 through FFFF). utf8mb4 is actual UTF-8 which can encode all Unicode code points. If your connection encoding is utf8, then all data is squeezed though this subset of UTF-8 and you cannot send or receive characters above the BMP to or from MySQL.

