After setting up a typecho blog, you may find that if you insert some small emoticons, they will not be displayed on the page after rendering, and all the content after the emoticons will disappear, resulting in a poor user experience.
The reason why the emoticons cannot be displayed is due to the uft-8 encoding issue, which cannot recognize the small emoticons. It needs to be changed to utf8mb4.
Step 1: Access the database#
First, log in to the database of the blog's backend, then click on SQL, and enter the following code:
alter table typecho_comments convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_contents convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_fields convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_metas convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_options convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_relationships convert to character set utf8mb4 collate utf8mb4_unicode_ci;
alter table typecho_users convert to character set utf8mb4 collate utf8mb4_unicode_ci;
Simply copy and paste, then click on the bottom right corner to execute.
Step 2: Modify the typecho configuration file#
I am using the Baota panel. Click on "Websites" on the left side, then click on the root directory of our website. After entering, you can find a file named "config.inc.php". Enter it and scroll to the bottom.
You can find 'charset' => 'utf8',
below. For a more intuitive display, I commented it out and rewrote it. In actual operation, you just need to change utf8
to utf8mb4
.
/** Define database parameters */
$db = new Typecho_Db('Pdo_Mysql', 'typecho_');
$db->addServer(array (
'host' => 'localhost',
'user' => 'blog',
'password' => 'blog',
/** 'charset' => 'utf8', */
'charset' => 'utf8mb4',
'port' => '3306',
'database' => 'blog',
), Typecho_Db::READ | Typecho_Db::WRITE);
Typecho_Db::set($db);
After re-entering the small emoticons in the article backend, save and go back to the page. The small emoticons will be successfully displayed.