I encountered a problem of string
encoding, actually I get from an Internet site this name: CENTRE ESPORTIU D'ALÀS
and I'm trying to save this into my DB. Actually the database table encoding is setted to utf8_unicode_ci
(using MySQL WorkBench).
When I store it in the database I'll get this: Centre Esportiu d'Al\u00e0s
.
For create the connection I use this code:
MySqlConnectionStringBuilder conn = new MySqlConnectionStringBuilder();
conn.Server = "localhost";
conn.Database = "sample";
conn.UserID = "root";
conn.Password = "root";
conn.CharacterSet = "utf8";
conn.Port = json.Port;
MySqlConnection connection = new MySqlConnection(conn.ToString());
connection.Open();
I store the value in the following way:
using (MySqlConnection connection = new DBConnection().Connect())
{
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = "INSERT INTO venue (name) VALUES (@name)";
command.Parameters.AddWithValue("@name", "CENTRE ESPORTIU D'ALÀS");
command.ExecuteNonQuery();
}
}
As I said in the DB I get: Centre Esportiu d'Al\u00e0s
. Any idea?
Thanks in advance for any help.