HTML表格/文本区域与表情符号存储到MySQL数据库

时间:2015-02-27 09:20:49

标签: html mysql forms html-entities emoji

我有一个小网站,用户可以在其中发布状态。如果用户使用表情符号(例如来自iOS)发布状态,则表情符号字符存储在MySQL数据库中,如下所示:😁

我正在使用带有utf8mb4的MySQL版本5.5:

+--------------------------+--------------------+
| 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               |
| collation_connection     | utf8mb4_general_ci |
| collation_database       | utf8mb4_general_ci |
| collation_server         | utf8mb4_general_ci |
+--------------------------+--------------------+

但Text / Emoji始终存储为HTML实体。 PHP文件是UTF-8编码的,表单如下所示:

<form id="submit_form" action="myAction.php" method="post">

我如何获得真正的表情符号字符而不是HTML实体?

1 个答案:

答案 0 :(得分:0)

卫生署!我忘记了<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

希望这对任何人都有帮助..