Re: MySQL Client unicode program
Hello. Look at output produced by: show variables like '%char%'; and show create table 'your_unicode_table'; If you use Unicode, the most obvious that all charsets should be the same. But if you see something else, probably you should correct that. More you may read at: http://dev.mysql.com/doc/mysql/en/Charset.html Koon Yue Lam [EMAIL PROTECTED] wrote: Hi, I am using MySQL 4.1.1 and all databases, columns are set to UTF-8 enco= ding I have try both MySQL cc and Query browser and try to enter some Chinese character, but when I print out the HEX value of the character. It isn't in Unicode that I expected, but i can't see those Chinese character using the above clients I can only insert correct Unicode character by using JSP page and a HTML form, encode all character in Unicode and send to database. However it is useless because I can't run some query directly to databse when the query contains Chinese character. How can I run an insert query directly to database and the data would be stored in Unicode? I have try prefix the character with character set and collation, and I got a warning : insert into tables set name =3D _utf8'=E6=97=A5' code 1265: Data truncated for column 'name' at row 1 If the query becomes this: insert into building set name =3D convert('=E6=97=A5' using 'utf8') I don't have warning and insert is OK, but the HEX is wrong the Unicode of '=E6=97=A5' should be E697A5,=20 but the above query insert a HEX value of 'C2A4C3A9' which I don't know what it is ... The only method that I can insert an unicode character is by using their Unicode directly in a query: insert into building set name =3D 0xE697A5 then everything are fine except I can't read it from any clients, but JSP can display it correctly. Anyone know what I am doing wrong?=20 Any help would be appreciated -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.NET http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Gleb Paharenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET ___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
Stormblade [EMAIL PROTECTED] wrote: Hopefully this will be the last snag...least till the next one :) I'm having a problem setting the charset to unicode (utf-8). If I understood what I read I can set each table to support a charset. But what I want to do is set the default charset for a database to be utf-8. Is this possible? If so how? Yes, it's possible from version 4.1.0. CREATE DATABASE db_name DEFAULT CHARACTER SET utf8; http://dev.mysql.com/doc/mysql/en/CREATE_DATABASE.html In any case, I need to be able to store unicode data and retrieve it. -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
On Tue, 20 Apr 2004 11:32:22 +0300, Victoria Reznichenko wrote: Stormblade [EMAIL PROTECTED] wrote: Hopefully this will be the last snag...least till the next one :) I'm having a problem setting the charset to unicode (utf-8). If I understood what I read I can set each table to support a charset. But what I want to do is set the default charset for a database to be utf-8. Is this possible? If so how? Yes, it's possible from version 4.1.0. CREATE DATABASE db_name DEFAULT CHARACTER SET utf8; http://dev.mysql.com/doc/mysql/en/CREATE_DATABASE.html Oh boy, that will be a pain. I use a GUI (Navicat and EMS MySQL Manager) and so far have not seen a way for me to make it create a table with a default character set. Nor even change it. Well at least I know it's possible. Thanks. In any case, I need to be able to store unicode data and retrieve it. -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net ___/ www.mysql.com -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Stormblade (Shaolin Code Warrior) Software Developer (15+ Years Programming exp.) My System: http://www.anandtech.com/mysystemrig.html?rigid=1683 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
At 9:38 -0400 4/20/04, Stormblade wrote: On Tue, 20 Apr 2004 11:32:22 +0300, Victoria Reznichenko wrote: Stormblade [EMAIL PROTECTED] wrote: Hopefully this will be the last snag...least till the next one :) I'm having a problem setting the charset to unicode (utf-8). If I understood what I read I can set each table to support a charset. But what I want to do is set the default charset for a database to be utf-8. Is this possible? If so how? Yes, it's possible from version 4.1.0. CREATE DATABASE db_name DEFAULT CHARACTER SET utf8; http://dev.mysql.com/doc/mysql/en/CREATE_DATABASE.html Oh boy, that will be a pain. I use a GUI (Navicat and EMS MySQL Manager) and so far have not seen a way for me to make it create a table with a default character set. Nor even change it. Um, what? If you specify a default character set when you create a database, any table created in that database will have the same character set by default. Is that not what you are asking? Well at least I know it's possible. Thanks. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
At 11:02 -0400 4/20/04, Stormblade wrote: On Tue, 20 Apr 2004 09:21:00 -0500, Paul DuBois wrote: At 9:38 -0400 4/20/04, Stormblade wrote: On Tue, 20 Apr 2004 11:32:22 +0300, Victoria Reznichenko wrote: Stormblade [EMAIL PROTECTED] wrote: Hopefully this will be the last snag...least till the next one :) I'm having a problem setting the charset to unicode (utf-8). If I understood what I read I can set each table to support a charset. But what I want to do is set the default charset for a database to be utf-8. Is this possible? If so how? Yes, it's possible from version 4.1.0. CREATE DATABASE db_name DEFAULT CHARACTER SET utf8; http://dev.mysql.com/doc/mysql/en/CREATE_DATABASE.html Oh boy, that will be a pain. I use a GUI (Navicat and EMS MySQL Manager) and so far have not seen a way for me to make it create a table with a default character set. Nor even change it. Um, what? If you specify a default character set when you create a database, any table created in that database will have the same character set by default. Is that not what you are asking? Yes and no. Whenever I go looking for MySQL help I generally see the command-line or manual way of doing things. This lets me know that at least it's possible. I wasn't even sure it was at the time I asked. So seeing the DDL for database creation answered that. However, I am not manually creating my databases. I have two GUI programs that I am using. Since that is outside the scope of this list I was merely commenting on the fact that I use these and that I hadn't seen a way to create a database or table with a specified char set. Okay. So that is an issue with those tools, not with MySQL. I've already sent some messages to their technical support. But from this list I really just wanted to know if it were possible and how to do it. I was hoping that I could change a setting somewhere to make utf-8 the default char set used for databases. Then I could see if Navicat or EMS MySQL Manager picked that up. Well, that isn't quite what you asked above, where you asked if you could specify the default character set for a database. For what you want, it might be better to change the server's default character set with the --default-character-set=utf8 option. For example, you can put this in an option file: [mysqld] default-character-set=utf8 That will cause utf8 to be the default character set for each database (and table, column, string) to be utf8. I don't know if you really want that, but it's at least possible to do this. It would not require the GUI tools to be aware of the character set setting. At this point though looks like I'll end up doing something else like creating all my tables and such then somehow exporting or copy and pasting the DLL for them all, modifying them so that it uses utf-8 and re-creating everything. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
At 13:03 -0400 4/20/04, Stormblade wrote: On Tue, 20 Apr 2004 11:49:46 -0500, Paul DuBois wrote: Make sure the server really is picking up the option value: SHOW VARIABLES LIKE 'character%'; Look for 'character_set_server'. If it's utf8, then perhaps your GUI tools are overriding the setting? Dunno. You might try creating a database through the GUI and then looking at the server query log to see what query is actually being sent to it. Using WinMySQLadmin 1.4 which came bundled with it I viewed the variables and it seems that it's not picking it up. The variable you mention is still set to latin1. Adding that line you mentioned didn't change anything. Is there a different format for the ini file on *Nix vs Windows? No. But you're asking me to guess what you did. What file did you add the lines to, and what lines did you add? Did you restart the server? The file was my ini file. my.ini which is located in the windows directory. I copy and pasted the line you gave here and put it under the [mysqld] section in that ini file. Yes I restarted the server. Hmm. That should have done it. There weren't any messages in the error log about the server not liking the option or anything? Here's my variables: character_set_server: latin1 character_set_system: utf8 character_set_database: latin1 character_set_client: latin1 character_set_connection: latin1 character_set_results: latin1 -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode (Solved)
Embarrassing but I blame it on hunger! It's working now. Bottom line was I hadn't restarted the server. Now I know I said I did. Here's where I blame hunger. I was restarted A server. My Tomcat server. I kept restarting it thinking I was restarting the MySQL serverdon't ask. Like I said I blame it on hunger. In any case, after a true restart it set all the variables to utf8 just fine. I went into Navicat and it picked it up just fine when I created a new database and table. So I just have to re-create the tables and re-import and I'm good to go. I may just re-create the tables (There's only 2) that will contain unicode data. Anyway, thanks for the help. I'm gonna go eat now. -- Stormblade (Shaolin Code Warrior) Software Developer (15+ Years Programming exp.) The worth of your opinion is in direct proportion to the number of people who have asked for it. My System: http://www.anandtech.com/mysystemrig.html?rigid=1683 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
On Tue, 20 Apr 2004 12:13:07 -0500, Paul DuBois wrote: At 13:03 -0400 4/20/04, Stormblade wrote: On Tue, 20 Apr 2004 11:49:46 -0500, Paul DuBois wrote: Make sure the server really is picking up the option value: SHOW VARIABLES LIKE 'character%'; Look for 'character_set_server'. If it's utf8, then perhaps your GUI tools are overriding the setting? Dunno. You might try creating a database through the GUI and then looking at the server query log to see what query is actually being sent to it. Using WinMySQLadmin 1.4 which came bundled with it I viewed the variables and it seems that it's not picking it up. The variable you mention is still set to latin1. Adding that line you mentioned didn't change anything. Is there a different format for the ini file on *Nix vs Windows? No. But you're asking me to guess what you did. What file did you add the lines to, and what lines did you add? Did you restart the server? The file was my ini file. my.ini which is located in the windows directory. I copy and pasted the line you gave here and put it under the [mysqld] section in that ini file. Yes I restarted the server. Hmm. That should have done it. There weren't any messages in the error log about the server not liking the option or anything? If by error log you mean the mysql.err file in the data subdirectory then no it shows only normal connections and shutdowns. No errors. Here's my variables: character_set_server: latin1 character_set_system: utf8 character_set_database: latin1 character_set_client: latin1 character_set_connection: latin1 character_set_results: latin1 -- Stormblade (Shaolin Code Warrior) Software Developer (15+ Years Programming exp.) The worth of your opinion is in direct proportion to the number of people who have asked for it. My System: http://www.anandtech.com/mysystemrig.html?rigid=1683 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
On Tue, 20 Apr 2004 11:49:46 -0500, Paul DuBois wrote: Make sure the server really is picking up the option value: SHOW VARIABLES LIKE 'character%'; Look for 'character_set_server'. If it's utf8, then perhaps your GUI tools are overriding the setting? Dunno. You might try creating a database through the GUI and then looking at the server query log to see what query is actually being sent to it. Using WinMySQLadmin 1.4 which came bundled with it I viewed the variables and it seems that it's not picking it up. The variable you mention is still set to latin1. Adding that line you mentioned didn't change anything. Is there a different format for the ini file on *Nix vs Windows? No. But you're asking me to guess what you did. What file did you add the lines to, and what lines did you add? Did you restart the server? The file was my ini file. my.ini which is located in the windows directory. I copy and pasted the line you gave here and put it under the [mysqld] section in that ini file. Yes I restarted the server. Here's my variables: character_set_server: latin1 character_set_system: utf8 character_set_database: latin1 character_set_client: latin1 character_set_connection: latin1 character_set_results: latin1 -- Stormblade (Shaolin Code Warrior) Software Developer (15+ Years Programming exp.) The worth of your opinion is in direct proportion to the number of people who have asked for it. My System: http://www.anandtech.com/mysystemrig.html?rigid=1683 -- Stormblade (Shaolin Code Warrior) Software Developer (15+ Years Programming exp.) The worth of your opinion is in direct proportion to the number of people who have asked for it. My System: http://www.anandtech.com/mysystemrig.html?rigid=1683 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
Hi, I have a question. I have read that since MySQL 4.1, VARCHAR type can hold unicode characters. But, it seems that the API of the C library use to send queries to the server still use 'const char*' for the type of the query. So, praticaly, if I have a unicode string stored in C, how can I use it with the C API? Thanks. I use unicode(UTF-8) strings as following. mysql_query( mysql, SELECT inlude Japanese characters(KANJI) ); I think that this might answer your question. Hirofumi Fujiwara (Tokyo JAPAN) enjoy JAVA and Puzzle World [EMAIL PROTECTED]http://www.pro.or.jp/~fuji/index-eng.html [EMAIL PROTECTED] Puzzle Japanhttp://www.puzzle.jp/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
OK, you use a C char* using an UTF-8 encoding. On Friday 09 April 2004 11:45, Hirofumi Fujiwara wrote: Hi, I have a question. I have read that since MySQL 4.1, VARCHAR type can hold unicode characters. But, it seems that the API of the C library use to send queries to the server still use 'const char*' for the type of the query. So, praticaly, if I have a unicode string stored in C, how can I use it with the C API? Thanks. I use unicode(UTF-8) strings as following. mysql_query( mysql, SELECT inlude Japanese characters(KANJI) ); I think that this might answer your question. Hirofumi Fujiwara (Tokyo JAPAN) enjoy JAVA and Puzzle World [EMAIL PROTECTED]http://www.pro.or.jp/~fuji/index-eng.html [EMAIL PROTECTED] Puzzle Japanhttp://www.puzzle.jp/ -- Prof. Pascal Francq Université Libre de Bruxelles CAD/CAM Department Avenue F.D. Roosevelt, 50 CP 165/14 B-1050 Brussels BELGIUM Tel. +32-2-650 47 65 Fax +32-2-650 47 24 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL and Unicode
Pascal Francq wrote: OK, you use a C char* using an UTF-8 encoding. That's very commmon in the Unix world. 2-byte encodings are very rare on Unix-like systems, for compatibility reasons. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: mysql and unicode ....
Not natively (i.e. you can't sort on a Unicode field, for example), but you can still store Unicode text in fields. Just use a BLOB or you can even use VARCHAR(), et al, but remember that you only get half as many Unicode characters as you specify in the field width... If you're using the native mysql API, you've also got to remember to escape all your text properly (i.e. cast it to a char * and convert any NULs to \0, etc). Some of the other APIs out there (JDBC or ODBC, etc) might have better binary support (i.e. you might not have to worry about it for them, just give a data pointer and field length to them) but I don't use them, so I'm not sure... Also realise that almost all the client tools out there don't recognise Unicode and so will only display the first character of your string (or something similar, depending on what's actually stored in the string). My application uses Unicode for almost everything (though I don't need to sort on any text fields so it's OK) and I've not had any problems... Dean Harding. -Original Message- From: toby - [mailto:[EMAIL PROTECTED]] Sent: Wednesday, 19 June 2002 5:13 pm To: [EMAIL PROTECTED] Subject: mysql and unicode does mysql 32.23.51 support unicode thnx a million ... toby . _ Send and receive Hotmail on your mobile device: http://mobile.msn.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php