文档主页
MySQL 8.4 C API 开发者指南
下载本手册
PDF (US Ltr) - 1.4Mb
PDF (A4) - 1.4Mb


MySQL 8.4 C API 开发者指南  /  ...  /  mysql_get_character_set_info()

5.4.28 mysql_get_character_set_info()

void
mysql_get_character_set_info(MYSQL *mysql,
                             MY_CHARSET_INFO *cs)

描述

此函数提供有关默认客户端字符集的信息。可以使用 mysql_set_character_set() 函数更改默认字符集。

示例

本示例显示了 MY_CHARSET_INFO 结构中可用的字段

if (!mysql_set_character_set(&mysql, "utf8"))
{
    MY_CHARSET_INFO cs;
    mysql_get_character_set_info(&mysql, &cs);
    printf("character set information:\n");
    printf("character set+collation number: %d\n", cs.number);
    printf("collation name: %s\n", cs.name);
    printf("character set name: %s\n", cs.csname);
    printf("comment: %s\n", cs.comment);
    printf("directory: %s\n", cs.dir);
    printf("multi byte character min. length: %d\n", cs.mbminlen);
    printf("multi byte character max. length: %d\n", cs.mbmaxlen);
}