Prokurors
Prokurors

Reputation: 2548

How to fix encoding for Dictionary<char, char>?

I created a simple Dictionary<char, char> that contains character combinations to replace local characters to ascii characters (ē -> e), but it does not work - when I see this dictionary in debug mode - I see, that local characters are wrong (instead of my local characters (latvian) I see some different characters)

I suspect it's something to do with encoding, although I don't know why is this happening and how to fix it...

if I make a simple string text = "with some local characters ā ē ū"; - if I check this in debug mode, encoding seems to be correct...

here is the instantiation of my dictionary: dictionary

and here is what values appear in this dictionary after instantiation: enter image description here

Upvotes: 2

Views: 1347

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20782

Check that your source is encoding per the C# language specification. It must use one of the allowed Unicode encodings. UTF-8 is always allowed. (I'd say preferred.) Your editor should be able to tell you which your using and/or allow you to re-save it with a specific encoding.

In Visual Studio, you can re-save the file with a specific encoding using File » Advanced Save Options…, then File » Save.

Upvotes: 1

Related Questions