How to make the application support emoji characters?

What is emoji?Β These expressions and symbols are:

πŸ˜€πŸ˜„πŸ’¦πŸ˜πŸ˜‚πŸ˜±πŸ˜­πŸ˜΄πŸ‘Œ

Since the iPhone from the iOS 5 in the input method began to support emoji since these expressions quickly swept the world. But many Web sites are not yet supported.

How to make the application support emoji characters?

How can support emoji? In fact, the code line is not changed, because the emoji symbol is actually text, not a picture, they only show a picture only. Moreover, emoji symbols have been standardized and encoded into the latest Unicode standard. So, to support emoji, only the need for the underlying software system support on it.

Server-side to properly store emoji symbols, only need to ensure that Web applications and the underlying database can support the latest Unicode standards on it.

If you use MySQL as a database, you need to upgrade to 5.5.3 or later, and then change the default code from the original utf8 to utf8mb4, in my.cnf or my.ini configuration file to modify the following:

[client]
default-character-set = utf8mb4

[mysqld]
character-set-server = utf8mb4
collation-server     = utf8mb4_general_ci

Then restart MySQL, and then use the following command to view the code, it should be utf8mb4 (except character_set_filesystem and character_set_system):

mysql> show variables like '%char%';
+--------------------------+--------------------------+
| Variable_name            | Value                    |
+--------------------------+--------------------------+
| character_set_client     | utf8mb4                  |
| character_set_connection | utf8mb4                  |
| character_set_database   | utf8mb4                  |
| character_set_filesystem | binary                   |
| character_set_results    | utf8mb4                  |
| character_set_server     | utf8mb4                  |
| character_set_system     | utf8                     |
| character_sets_dir       | /usr/local/mysql-5.7.... |
+--------------------------+--------------------------+
8 rows in set (0.00 sec)

Use the command to view the collation settings, it should be utf8mb4_general_ci:

mysql> show variables like '%coll%';
+----------------------+--------------------+
| Variable_name        | Value              |
+----------------------+--------------------+
| collation_connection | utf8mb4_general_ci |
| collation_database   | utf8mb4_general_ci |
| collation_server     | utf8mb4_general_ci |
+----------------------+--------------------+
3 rows in set (0.01 sec)

If character_set_database is still utf8, you need to reboot the server.

Now, MySQL can correctly store emoji characters.

Web software

To support emoji, the need for Web software is also supported. At present, known support emoji include:

  • Java 8
  • Node