MYSQLutf8mb4 insert emoji garbled characters

Source: Internet
Author: User
About MYSQLutf8mb4 string set. The table structure is as follows: Code {code...} is? For example, solve the problem.

About MYSQL utf8mb4 string set.

The table structure is as follows:

The following code:

$ Db = new mysqli ('X', 'XXX', 'xxxxx'); $ db-> select_db ('XXX '); $ db-> set_charset ('utf8mb4'); // Here is an emoji expression $ contents = <
  
   
Query ($ SQL); print_r ($ db-> error_list); echo "\ t \ n"; exit ();
  

However?For example:

Solve the problem.

Reply content:

About MYSQL utf8mb4 string set.

The table structure is as follows:

The following code:

$ Db = new mysqli ('X', 'XXX', 'xxxxx'); $ db-> select_db ('XXX '); $ db-> set_charset ('utf8mb4'); // Here is an emoji expression $ contents = <
  
   
Query ($ SQL); print_r ($ db-> error_list); echo "\ t \ n"; exit ();
  

However?For example:

Solve the problem.

This is correct.
To put it down, the difference between utf8mb4 and utf8 is that utf8 uses three-bit bytecode to store data, while utf8mb4 uses four-bit bytecode to store data.
An emoji is a four-byte code that is escaped from the previous paragraph. it is an unreadable character, so "?" is displayed on the database client.
The emoji expression is displayed in the area where the front-end supports emoji.

Determine whether the client supports utf8mb4. it is best to use set names.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.