<C#> The characters like "ä", "ö" or "å" drop out of the console input

317 views Asked by At

I have a c# console application that needs input that contains characters like "ä", "ö" or "å". But these characters drop out of the input. For example if the user input is "abc äöå" it is delivered to the program as "abc " an anyone help?

1

There are 1 answers

0
Reza Heidari On BEST ANSWER

You can change encoding as per below snippet code:

        Console.OutputEncoding = Console.InputEncoding = Encoding.Unicode;
        Console.Write("سلام بر برنامه نویس عزیز");
        string name = Console.ReadLine();
        Console.WriteLine($"اسم  {name}");

And the output:

Using Unicode in Console Window

For more information check How to use character encoding classes in .NET