mysql_character_set_name()
const char *mysql_character_set_name(MYSQL *mysql)
This function returns the name of the default character set in use by the MySQL server. Here is an example:
...
MYSQL *mysql;
const char *char_set;
mysql = mysql_init(NULL);
mysql_real_connect(mysql,"localhost","russell","my_pwd","test","3306",
NULL,0);
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