Neno
Neno

Reputation: 767

Reading č, ć and đ from MySQL using .NET Core service

I tried number of options for reading ć, ć and đ signs from MySQL database but with no success. Instead of: šuma, žeton, čevepčići, šuma, đak, džon

I am getting: šuma, žeton, ?evep?i?i, šuma, ?ak, džon.

The collation of MySQl table is utfmb4- default collation. The very same .NET Core service having trouble reading mentioned signs from database can do insert operation perfectly. So just a read is a problem.

Some members here on SO advised that executing following "SET character" commands after opening connection to database should help, but this was not true for me.

 string commColl = "SET character_set_client = 'utf8mb4'; set character_set_results = 'utf8mb4'; SET collation_connection = 'utf8mb4_general_ci'; SET NAMES UTF8;";

            MySqlCommand commCollation = new MySqlCommand(commColl, conn);

            try
            {
                conn.Open();
                commCollation.ExecuteNonQuery();

Also, I tried with setting to 'utf8' also without success. Besides, I have also put the CharSet part into connection string:

 private readonly string connString = "host=aurora-host.wert.net;user=asop;password=ooppoo;database=test;Connect Timeout=10;CharSet=utf8;";

Show CREATE TABLE:

CREATE TABLE FEEDBACK ( EntryID int(11) NOT NULL AUTO_INCREMENT, AccessCode varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL, DocumentPath varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, FreeText varchar(4000) COLLATE utf8mb4_unicode_ci DEFAULT NULL, DateInsert datetime DEFAULT NULL, SurveyID int(11) DEFAULT NULL, Document blob, DocumentExtension varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL, CompanyID int(11) DEFAULT NULL, PRIMARY KEY (EntryID) ) ENGINE=InnoDB AUTO_INCREMENT=98 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Upvotes: 0

Views: 279

Answers (1)

Neno
Neno

Reputation: 767

So, the problem was that the stored procedure retrieving data referenced a column in another table which had swedish_latin_ci collation.

utf8 charset and utf8_general_ci collation is enough.

Upvotes: 0

Related Questions