What is a character set
Character is the general name of various characters and symbols, including national characters, punctuation marks, graphic symbols, numbers and so on. A character set is a collection of multiple characters. There are many types of character sets, and each character set contains different numbers of characters. To accurately process various character sets of characters, the computer needs to carry out character encoding, while the computer can learn and store various characters. Common character sets are as follows:
Character set | instructions |
---|---|
ASCII | The simplest western encoding scheme, mainly used to display modern English and other Western European languages. A byte can be used to represent 128 characters |
GB2312 | National standard Simplified Chinese character set, compatible with ASCII. Using two bytes, it can represent 7445 characters, including 6763 Chinese characters, covering almost all high-frequency Chinese characters. |
GBK | GB2312 extension, add support for traditional Characters, compatible with GB2312. Using two bytes, it can represent 21886 characters. |
GB18030 | Solve the Chinese, Japanese, Korean and other coding, compatible with GBK. Represented by variable bytes (1 ASCII, 2,4 bytes). Grams represent 27,484 characters. |
Unicode | Unicode is the international standard encoding character set, which is used for 650 languages worldwide and is compatible with ISO-8859-1. The Unicode character set has multiple encodings, namely UTF-8, UTF-16, and UTF-32. |
2. Set character set
1. The database
Create a database with a character setcreate database databaseName charset utf8 collateutf8_general_ci; Check the character set of the databaseshow create database databaseName;
Copy the code
2. The table
Create table char setcreate table tableName(...) default charset=utf8; Check the character set of the databaseshow create table tableNamel
Copy the code
3. The field
# specify the field encodingcreate tabletableName(... ,namevarchar(50) not nullcharset utf8,..) ;Copy the code