Re: Problems setting connection charset
Ok, I managed to make some - questionable - progress.
I managed to replace the "SET NAMES" and "SET CHARACTER SET" queries with a call to mysql_set_character_set() function :
//////////////////////////////////////////////////////////////////////////////////////
if( ! mysql_set_character_set( node->front_db, "utf8" ) )
printf("Success\n");
printf("Connection charset: %s\n", mysql_character_set_name(node->front_db) );
//////////////////////////////////////////////////////////////////////////////////////
Now, that prints "utf8" as desired ( before I couldn't link my app with a call to this function, now I've included the 'mysqlclient.lib' library and things build. BTW, why is this particular function all of the sudden in 'mysqlclient.lib' rather than 'libmysql.h' ? )
However, in terms of functionality, things on only got worse: now it completely eats up all Chinese characters I insert to the DB: ( VC++ code )
//////////////////////////////////////////////////////////////////////////////////////
CString cmd = "UPDATE products SET NAME= \'ABC <here some chinese stuff> DEF \' ";
int len = cmd.GetLength();
char* command = (char*) malloc( 2*len+1 );
int real_len = mysql_real_escape_string( db, command, cmd, len );
int ret = mysql_real_query( db, command , real_len );
if( ret != 0 ) { /* handle errors ... */ }
free( command );
//////////////////////////////////////////////////////////////////////////////////////
Now, a "SELECT NAME FROM products" issued from CLI retrieves
ABCDEF
and all the Chinese stuff in between is gone ???
Leszek
Subject
Views
Written By
Posted
5307
September 05, 2005 09:31AM
Re: Problems setting connection charset
2084
September 05, 2005 10:04PM
2069
October 21, 2005 04:51AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.