Documentation Home
MySQL 8.0 C API 开发者指南  / 第 5 章 C API 基本接口  / 5.4 C API 基本功能说明  /  5.4.26 mysql_get_character_set_info() 函数

5.4.26 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("character set name: %s\n", cs.name);
    printf("collation 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);
}