ico303 0 Newbie Poster

I have a question about C and mysql.

I have a C program that connect to a mysql DB. One of the tables has a cp1251-encoded cyrillic column and when I read it with C I get ???? ?? ???

So is there a way to specify the cp1251 encoding to the query (just as it is done in php) in my C program?

Part of my C code is:

conn = mysql_init(NULL);

   /* Connect to database */
   if (!mysql_real_connect(conn, server,
         user, password, database, 0, NULL, 0)) {
      fprintf(stderr, "%s\n", mysql_error(conn));
     // exit(1);
   }

    // razdeliane na ziavkata na chasti za da moga da sloja v neia promenliva
    sprintf(query1, "SELECT f.Tmin, Tmax, f.Phen, b.sin_kod, b.namen, LEFT(f.timea, 10), SUBSTRING(f.timea, 12, 2), s.sin_name "
		  "FROM fcs f, bgc b, sinoptic s "
		  "WHERE term = \'"); 
    sprintf(query2, "\' and b.sin_kod>15500 and b.sin_kod<15741 and b.id=f.site and f.fore=s.sin_id ORDER BY f.timea DESC");
    sprintf(query,"%s%s%s", query1, forecast_date, query2);

   /* send SQL query */
   if (mysql_query(conn, query)) {
      fprintf(stderr, "%s\n", mysql_error(conn));
     // exit(1);
   }