You can call the mysql_set_character_set() function to set the default character set for the current connection.
Syntax
int
mysql_set_character_set(MYSQL *mysql,
const char *csname)
The string csname specifies a valid character set name.
Return values
0 is returned for an execution success, and a non-zero value is returned for errors.
Notes
The connection collation becomes the default collation of the character set. This function is similar to the SET NAMES statement, but it sets the value of mysql->charset and thus affects the character set used by mysql_real_escape_string().