Tom
Tom

Reputation: 323

Encoding issue when save string "Don’t do it" by ServiceStack and Ormlite to MySQL

Save object with string Don’t do it by ServiceStack and OrmLite to MySQL.

The string changed to Don’t do it in MySQL.

If I read the value from MySQL and save again, then get Don’t do it

It only happened on one Windows server 2016 with .net 4.62, it works correctly on other Windows with .net 4.62 and OSX with Mono.

ServiceStack libraries version is "4.5.0"; MySQL version is 5.6.23; The database table and column charset are UTF-8.

It may be somewhere do the wrong encoding escape and repeat it again and again. I upgraded from .net 4.5 to 4.62 recently.

I can not debug it: it works on developing MAC, and test Windows; it only failed in the production environment.

Upvotes: 2

Views: 209

Answers (1)

Tom
Tom

Reputation: 323

The problem has sorted out:

It's from the MySQL connection string. We recently added the "ConnectionReset=True;" which triggered this encoding issue.

It will convert a UTF-8 string to be read as Western 1252 encoding; so a ’ will be displayed as ’, and so on

It is able to reproduce on another Windows Server.

After setting it to false or remove it; it fixed.

Upvotes: 2

Related Questions