EIMA
EIMA

Reputation: 11

Visual Studio C# swaps characters

My problem is that when, for example, word "Eglė" is red it is changed to "Egle". I mean, character Ė is now E.

I know it has something to do with character encoding. I can output these language specific characters (like č, ė, š, ų) by manually writing a string like Console.WriteLine("Aš esu Eimantas"), but not by passing it a string variable with those chracters.

Console.OutputEncoding = Encoding.Unicode;
string name;
Console.WriteLine("Įveskite savo vardą");
name = Console.ReadLine();
Console.WriteLine(name);

When I input name "Eglė" I expect to get the same thing but I get "Egle"

Upvotes: 1

Views: 50

Answers (1)

adjan
adjan

Reputation: 13684

Try setting the input encoding as well:

Console.InputEncoding = Encoding.Unicode;

Upvotes: 2

Related Questions