官术网_书友最值得收藏!

Character sets and collations

A character set describes how symbols for a specific language or dialect are encoded. A collation contains rules to compare and sort the characters of a character set. The character set used to store our data may be different from the one used to display it, leading to data discrepancies. Thus, a need to transform the data arises.

Since MySQL 4.1.x, the MySQL server does the character recoding work for us. Also, MySQL enables us to indicate the character set and collation for each database, each table, and even each field. A default character set for a database applies to each of its tables, unless it is overridden at the table level. The same principle applies to every column.

Effective character sets and collations

On the home page, we can see the MySQL charset information and a MySQL connection collation selector. Here is the MySQL charset information:

Effective character sets and collations

The character set information (as seen here after MySQL charset) is used to generate HTML information, which tells the browser what is the page's character set.

We can also choose which character set and collation will be used for our connection to the MySQL server using the MySQL connection collation dialog. This is passed to the MySQL server. MySQL then transforms the characters that will be sent to our browser into this character set. MySQL also interprets what it receives from the browser according to the character set information. Remember that all tables and columns have a character set information describing how their data is encoded.

Effective character sets and collations

Normally, the default value should work. However, if we are entering some characters using a different character set, we can choose the proper character set in this dialog.

The following parameter defines both the default connection collation and character set:

$cfg['DefaultConnectionCollation'] = 'utf8_unicode_ci';
主站蜘蛛池模板: 滁州市| 昌平区| 淅川县| 天峻县| 永寿县| 柳河县| 响水县| 富蕴县| 精河县| 嘉祥县| 平利县| 噶尔县| 永寿县| 泰安市| 二连浩特市| 马公市| 苏尼特右旗| 盖州市| 阿拉善左旗| 奇台县| 霞浦县| 桑植县| 肃宁县| 商水县| 广河县| 平谷区| 平安县| 盖州市| 阿拉善盟| 吉水县| 岱山县| 孙吴县| 金溪县| 安溪县| 马鞍山市| 和龙市| 通化县| 盈江县| 遂昌县| 海晏县| 汝阳县|