Problem with encoding

Problem with encoding

Postby e-nvention.com » Fri 15 Sep 2006 13:57

Hi there,

I have a problem when reading data out of the MySQL Database, I use the following connection string:

Code: Select all
databaseConnection="User Id=***;Password=***;Host=***;Database=***;Unicode=True;


Now in some of my datarows I have some data with special encoding. I.e. "Zürich" and when it is read out of the database it should read "Zürich".

Am I missing a setting? In another application that is written in Java I have no problem with reading out the data correctly.

Any help would be appriciated.

Thanks a lot.
Cedric
e-nvention.com
 
Posts: 2
Joined: Fri 15 Sep 2006 13:49
Location: Lucerne, Switzerland

Postby Alexey » Mon 18 Sep 2006 07:43

Send us small test project if possible to reproduce the problem; it is
desirable to use 'test' schema objects, otherwise include definition of
your own database objects. Do not use third party components. Include your client and server machines' regional settings.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby e-nvention.com » Mon 18 Sep 2006 10:28

Email sent to your support address.

Thanks.
Cedric
e-nvention.com
 
Posts: 2
Joined: Fri 15 Sep 2006 13:49
Location: Lucerne, Switzerland

Postby Alexey » Mon 18 Sep 2006 10:43

OK. Look forward to the reply.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Alexey » Thu 28 Sep 2006 10:10

You 've been answered by e-mail.
Alexey
 
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Postby Serious » Tue 17 Oct 2006 09:03

We think you have invalid data stored in your database.

We reproduced the problem when using mysql command line client to create and fill table. In this case data is stored in cp850 charset. When filling table with MySQLDirect .NET data is stored in latin1 (codepage 1252) charset and no error occurs.

Behaviour does not change if you alter storage option for table column (e.g. CHARACTER SET utf8 COLLATE utf8_general_ci). This means that problem is in data format.

To check that data inserted with MySQLDirect .NET is valid and recognized by server perform 'select upper(city) from afpe_organization' query. Data stored with MySQLDirect .NET will be returned in uppercase, data stored with mysql command line client will not. This means that server cannot identify characters in invalid codepage and does not perform uppercase transformation on some symbols.

We recommend you to fix the database. If this is impossible you can receive any charset data in the following way:

when using Unicode=false
Code: Select all
byte[] data = new byte[256];
int count = (int)reader.GetBytes(columnOffset, 0, data, 0, data.Length);
Console.WriteLine(Encoding.GetEncoding(850).GetString(data, 0, count));
when using Unicode=true
Code: Select all
byte[] data = new byte[256];
int count = (int)reader.GetBytes(columnOffset, 0, data, 0, data.Length);
string defaultString = Encoding.UTF8.GetString(data, 0, count);
byte[] cp850data = Encoding.Default.GetBytes(defaultString);
Console.WriteLine(Encoding.GetEncoding(850).GetString(cp850data));
Serious
 


Return to dotConnect for MySQL