RE: MySQL 5.0.27: character problem
I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Wednesday, December 13, 2006 2:03 PM To: mysql@lists.mysql.com Subject: MySQL 5.0.27: character problem Hello, I'm using MySQL version 5.0.27 under Windows XP professional. I have a text file with some SQL commands (I create a few tables and insert some rows into them). I noticed that all columns where I tried to insert a swedish character, that character got corrupted. But it works if I type the same explicitly in mysql monitor. What do I need to do so I can use command files and still have proper handling of swedish characters? - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL 5.0.27: character problem
Thanks for the reply, Mr Schwartz. I will see if I can find some clue on how to write such a program myself. - Eric Jerry Schwartz skrev: I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Wednesday, December 13, 2006 2:03 PM To: mysql@lists.mysql.com Subject: MySQL 5.0.27: character problem Hello, I'm using MySQL version 5.0.27 under Windows XP professional. I have a text file with some SQL commands (I create a few tables and insert some rows into them). I noticed that all columns where I tried to insert a swedish character, that character got corrupted. But it works if I type the same explicitly in mysql monitor. What do I need to do so I can use command files and still have proper handling of swedish characters? - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: MySQL 5.0.27: character problem
I did it in PHP, using the iconv() function. I do batches, with the CP1252 (my original message was wrong) files named *.orig. I am doing this to build web pages, but I think it might serve your purpose with minor modifications. Note that the PHP folks warned me that PHP is not really UTF-8 safe! So far, this appears to work; but you might want to use Perl instead. I don't even know if iconv() supports the character set you want. There's another possibility, by the way. I seem to recall that you have to make sure the character set used by the server, the client, and the connection are what you want (not to mention the data base, the table, and the fields). Look at this: mysql show variables like char%; +--++ | Variable_name| Value | +--++ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_results| latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--++ 7 rows in set (0.03 sec) In this case, the data base I'm using has a default character set of UTF-8. I forget if any of these are specific to the mysql command line client. You can change a bunch of them in one shot with the SET NAMES command in that client. Section 10.3.6 of the reference manual (I use the off line version for speed) discusses this. Multiple character sets give me a severe headache. ?php // This little script searches the current directory for *.orig, converts from the Windows // code page to UTF-8, and stuffs the results into the target for use in the web site foreach (glob(*.orig) as $file_to_convert) { $text_to_convert = file_get_contents($file_to_convert); $text_converted = iconv(cp1252,utf-8,$text_to_convert); file_put_contents(basename($file_to_convert,.orig), $text_converted); } ? Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Thursday, December 14, 2006 2:13 PM To: mysql@lists.mysql.com Subject: Re: MySQL 5.0.27: character problem Thanks for the reply, Mr Schwartz. I will see if I can find some clue on how to write such a program myself. - Eric Jerry Schwartz skrev: I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Wednesday, December 13, 2006 2:03 PM To: mysql@lists.mysql.com Subject: MySQL 5.0.27: character problem Hello, I'm using MySQL version 5.0.27 under Windows XP professional. I have a text file with some SQL commands (I create a few tables and insert some rows into them). I noticed that all columns where I tried to insert a swedish character, that character got corrupted. But it works if I type the same explicitly in mysql monitor. What do I need to do so I can use command files and still have proper handling of swedish characters? - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL 5.0.27: character problem
Here's what I get when I perform mysql show variables like char%; +--+-+ | Variable_name| Value | +--+-+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results| latin1 | | character_set_server | latin1 | | character_set_system | utf8| | character_sets_dir | C:\mysql_5.0.27\share\charsets\ | +--+-+ So it seem my windows character set is utf8 and I need to convert my scripts from utf8 to latin1 so I can use them properly in MySQL (so åäöÅÄÖ does not get corrupted), right? - Eric Jerry Schwartz skrev: I did it in PHP, using the iconv() function. I do batches, with the CP1252 (my original message was wrong) files named *.orig. I am doing this to build web pages, but I think it might serve your purpose with minor modifications. Note that the PHP folks warned me that PHP is not really UTF-8 safe! So far, this appears to work; but you might want to use Perl instead. I don't even know if iconv() supports the character set you want. There's another possibility, by the way. I seem to recall that you have to make sure the character set used by the server, the client, and the connection are what you want (not to mention the data base, the table, and the fields). Look at this: mysql show variables like char%; +--++ | Variable_name| Value | +--++ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_results| latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--++ 7 rows in set (0.03 sec) In this case, the data base I'm using has a default character set of UTF-8. I forget if any of these are specific to the mysql command line client. You can change a bunch of them in one shot with the SET NAMES command in that client. Section 10.3.6 of the reference manual (I use the off line version for speed) discusses this. Multiple character sets give me a severe headache. ?php // This little script searches the current directory for *.orig, converts from the Windows // code page to UTF-8, and stuffs the results into the target for use in the web site foreach (glob(*.orig) as $file_to_convert) { $text_to_convert = file_get_contents($file_to_convert); $text_converted = iconv(cp1252,utf-8,$text_to_convert); file_put_contents(basename($file_to_convert,.orig), $text_converted); } ? Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Thursday, December 14, 2006 2:13 PM To: mysql@lists.mysql.com Subject: Re: MySQL 5.0.27: character problem Thanks for the reply, Mr Schwartz. I will see if I can find some clue on how to write such a program myself. - Eric Jerry Schwartz skrev: I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Wednesday, December 13, 2006 2:03 PM To: mysql@lists.mysql.com Subject: MySQL 5.0.27: character problem Hello, I'm using MySQL version 5.0.27 under Windows XP professional. I have a text file with some SQL commands (I create a few tables and insert some rows into them). I noticed that all columns where I tried to insert a swedish character, that character got corrupted. But it works if I type the same explicitly in mysql monitor. What do I need to do so I can use command files and still have proper handling of swedish characters? - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http
RE: MySQL 5.0.27: character problem
I'm not sure you haven't got it backwards. I don't really know what character_set_system means, unless it is the character set that the server uses to create file names or some such. The real question is, what does your query-creating editor speak? As I said, I get very confused. When I figured this out enough to get it working, I was still on shaky ground. Sorry I can't help more. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Thursday, December 14, 2006 4:36 PM To: mysql@lists.mysql.com Subject: Re: MySQL 5.0.27: character problem Here's what I get when I perform mysql show variables like char%; +--+-+ | Variable_name| Value | +--+-+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results| latin1 | | character_set_server | latin1 | | character_set_system | utf8| | character_sets_dir | C:\mysql_5.0.27\share\charsets\ | +--+-+ So it seem my windows character set is utf8 and I need to convert my scripts from utf8 to latin1 so I can use them properly in MySQL (so åäöÅÄÖ does not get corrupted), right? - Eric Jerry Schwartz skrev: I did it in PHP, using the iconv() function. I do batches, with the CP1252 (my original message was wrong) files named *.orig. I am doing this to build web pages, but I think it might serve your purpose with minor modifications. Note that the PHP folks warned me that PHP is not really UTF-8 safe! So far, this appears to work; but you might want to use Perl instead. I don't even know if iconv() supports the character set you want. There's another possibility, by the way. I seem to recall that you have to make sure the character set used by the server, the client, and the connection are what you want (not to mention the data base, the table, and the fields). Look at this: mysql show variables like char%; +--++ | Variable_name| Value | +--++ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_results| latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--++ 7 rows in set (0.03 sec) In this case, the data base I'm using has a default character set of UTF-8. I forget if any of these are specific to the mysql command line client. You can change a bunch of them in one shot with the SET NAMES command in that client. Section 10.3.6 of the reference manual (I use the off line version for speed) discusses this. Multiple character sets give me a severe headache. ?php // This little script searches the current directory for *.orig, converts from the Windows // code page to UTF-8, and stuffs the results into the target for use in the web site foreach (glob(*.orig) as $file_to_convert) { $text_to_convert = file_get_contents($file_to_convert); $text_converted = iconv(cp1252,utf-8,$text_to_convert); file_put_contents(basename($file_to_convert,.orig), $text_converted); } ? Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Thursday, December 14, 2006 2:13 PM To: mysql@lists.mysql.com Subject: Re: MySQL 5.0.27: character problem Thanks for the reply, Mr Schwartz. I will see if I can find some clue on how to write such a program myself. - Eric Jerry Schwartz skrev: I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT
Re: MySQL 5.0.27: character problem
Thanks for the help, Jerry, I think I solved it. I opened the script (a standard windows text file) in UltraEdit. It can convert between some different text formats. After some experimenting it seems that selecting the conversion ansi-to-oem does the trick! It's now inserted properly into mysql. Can't say I understand any of this, though, just happened to find a way that seems to work, heh. - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: MySQL 5.0.27: character problem
Eric, I think that you don't have to write a conversion program because MySQL have built-in pretty good character set conversions. All you need to do is to tell MySQL which character set uses your file with your SQL commands. Create your file with one of the character sets MySQL understands and put as a first command to execute SET NAMES 'character_set_of_your_file' You can check MySQL's character sets by executing command SHOW CHARACTER SET. HTH, Dusan Eric Lilja napsal(a): Thanks for the reply, Mr Schwartz. I will see if I can find some clue on how to write such a program myself. - Eric Jerry Schwartz skrev: I have run into this as well. Windows uses CP-1522 (if I remember correctly), which is not exactly equivalent to UTF-8. I presume it is also not exactly equivalent to the character set you're using for MySQL. I wound up writing a program to convert the one character set to the other. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Eric Lilja Sent: Wednesday, December 13, 2006 2:03 PM To: mysql@lists.mysql.com Subject: MySQL 5.0.27: character problem Hello, I'm using MySQL version 5.0.27 under Windows XP professional. I have a text file with some SQL commands (I create a few tables and insert some rows into them). I noticed that all columns where I tried to insert a swedish character, that character got corrupted. But it works if I type the same explicitly in mysql monitor. What do I need to do so I can use command files and still have proper handling of swedish characters? - Eric -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]