Bug #42500 Mysql Connector .net 5.2 Character Set problem
Submitted: 31 Jan 2009 14:42 Modified: 11 Feb 2009 15:14
Reporter: Mesut AKSAK Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.2.5.0 OS:Windows (XP Pro Visual Studio 2008)
Assigned to: CPU Architecture:Any
Tags: Mysql Connector .net 5.2 Character Set problem

[31 Jan 2009 14:42] Mesut AKSAK
Description:
Hi,
I used mysql connector 5.2.5 and mysql server 5.1 in my c# project.
Im using latin5 charset, also l have setup mysql server default charset latin5.

l dont have problem with Turkish Character Set but when l have used € symbol in queries shown like ? ,

l have written sample code below please look at.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using MySql.Data.MySqlClient;

namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            MySqlConnection connection = new MySqlConnection();
            connection.ConnectionString =
                "server=localhost;user id=root;password=****;persist security info=True;database=new_db;Character Set=latin5";
            connection.Open();

            MySqlCommand command = new MySqlCommand();
            command.Connection = connection;
            command.CommandType = CommandType.Text;
            
            command.CommandText = @"
DROP TABLE IF EXISTS table_test;
CREATE TABLE table_test(
  colid INT (11) NOT NULL AUTO_INCREMENT,
  colname VARCHAR (150) NOT NULL,
  PRIMARY KEY (colid)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET latin5
COLLATE latin5_turkish_ci;";
            command.ExecuteNonQuery();
            Console.WriteLine("Executed : {0}\r\n", command.CommandText);

            // using turkish characters and € symbol
            command.CommandText = @"INSERT INTO table_test VALUES (NULL, 'şüçğı'), (NULL, '€')";
            command.ExecuteNonQuery();
            Console.WriteLine("Executed : {0}\r\n", command.CommandText);

            // reading data 
            command.CommandText = "SELECT `colid`, `colname` FROM table_test";
            MySqlDataReader reader = command.ExecuteReader();

            try
            {
                if (reader.HasRows)
                    while (reader.Read())
                        Console.WriteLine(String.Format("Row {0} - {1}", reader.GetInt32(0), reader.GetString(1)));
            }
            finally
            {
                if (!reader.IsClosed)
                reader.Close();
            }
        }
    }
}

Here Outputs

Executed : 
DROP TABLE IF EXISTS table_test;
CREATE TABLE table_test(
  colid INT (11) NOT NULL AUTO_INCREMENT,
  colname VARCHAR (150) NOT NULL,
  PRIMARY KEY (colid)
)
ENGINE = INNODB
AUTO_INCREMENT = 1
CHARACTER SET latin5
COLLATE latin5_turkish_ci;

Executed : INSERT INTO table_test VALUES (NULL, 'şüçğı'), (NULL, '?')

Row 1 - şüçğı
Row 2 - ?

Turkish characters are ok but € symbol is not

Thank you very much now
Regards

How to repeat:
Please send solution my email adress
[11 Feb 2009 13:43] Susanne Ebrecht
Many thanks for writing a bug report.

Your problem is not a bug.

Latin5 is according to iso-8859-9

http://en.wikipedia.org/wiki/ISO/IEC_8859-9

When you look into the link above then you will figure out that this character set don't support Euro sign (€).

When you want to store Turkish and Euro sign and maybe some other characters not given in Latin5 you should use utf8.
[11 Feb 2009 13:45] Tonci Grgin
Thanks for explanation Susanne.
[11 Feb 2009 15:14] Mesut AKSAK
Thank you very much for explanation