unicode and C API

2005-05-24 Thread Patrice Serrand
Hello,
I have an InnoDB table running on MySQL 4.1.11 

The MySQL server configuration use : default-character-set=utf8

I have a table unicode_tbl with 'default charset set utf8' and a field szWord 
varchar(50) character set utf8 collate utf8_general_ci.

if  I use the C API like this :
mysql_query (mysql, INSERT INTO db_unicode.unicode_tbl VALUES (6, _utf8 
'atüpedâ' COLLATE utf8_general_ci));
I get the string 'at' in my table.

If I use the same query in 'MySQL Query Browser' I can get the whole string 
'atüpedâ' in my table.
To get the same result I have to write : 
mysql_query (mysql, INSERT INTO db_unicode.unicode_tbl VALUES (6, 
'atüpedâ'));

Everything works like if the C API only accepts ANSI strings.

Is it possible to directly insert an unicode string using the C API ?
Is it possible to get in MYSQL_ROW an unicode string after performing a select 
for example using : swprintf(w_out, _T(%s\n), row[1]); ?

If not is MySQL 5.x will allow this ? when ?

Thanks in advance 

Patrice Serrand

Re: unicode and C API

2005-05-24 Thread Warren Young

Patrice Serrand wrote:


mysql_query (mysql, INSERT INTO db_unicode.unicode_tbl VALUES (6, _utf8 
'atüpedâ' COLLATE utf8_general_ci));


I'm no Unicode expert, but I've never seen that _utf8 bit before.  What 
is it?  Or more accurately, what do you expect it to do?  I ask because 
that string is probably already in UTF-8 form, if your text editor is 
UTF-8 aware.  The common Unix text editors are, as is the editor in the 
Visual Studio IDE.


I've done very similar things with MySQL++, the C++ wrapper for the C 
API, which I maintain.  http://tangentsoft.net/mysql++/  No _utf8 stuff 
was required.  Check out examples/resetdb.cpp and examples/custom3.cpp 
in the distribution.



Everything works like if the C API only accepts ANSI strings.


Nonsense.  All the C API cares about are null-terminated C strings, 
which UTF-8 data is.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]