kroneckerx
kroneckerx

Reputation: 13

utf-8 error in partial class

In my form application, I create a partial class of the form like designer to reduce complexity of code with categorizing the methods (I could use different classes but it's not possible at this point).

I have a string value that contains several utf-8 characters.

string t = "şçıer";

if I declare this string in partial form that I created, when I try to pop up a message box to show this string something go wrong.

Result: þçýer

But it's okay when I declare it in form1.cs

Upvotes: 1

Views: 87

Answers (1)

DevSolar
DevSolar

Reputation: 70333

Encoding mismatch.

0xfe is ş in Latin-5, and þ in Latin-1, Latin-6, Latin-9, and CP-1252.

0xfd is ı in Latin-5, and ý in Latin-1, Latin-6, Latin-9, and CP-1252.

ş in UTF-8 would be 0xc5 0x9f, and ı would be 0xc4 0xb1.

So some part in your chain is either in the wrong encoding, or declaring the wrong encoding. Make sure you are actually using UTF-8 throughout, because evidence suggests you are using Latin-5 (ISO-8859-9) in your source, and interpreting it as Latin-1 (or one of the other encodings mentioned above).

Upvotes: 3

Related Questions