Name

mysql_character_set_name( )

Synopsis

const char *mysql_character_set_name(MYSQL *mysql)

This returns the name of the default character set in use by the MySQL server.

...
MYSQL *mysql;
const char *char_set;
mysql = mysql_init(NULL);
mysql_connect(mysql,"localhost","russell","password");
char_set = mysql_character_set_name(mysql);
printf("Character Set: %s \n", char_set);
...

To get just the character set name, it’s not necessary to select a database. Here are what the results of running this program might look like:

Character Set: latin1

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.