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

Time:04-17

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?

CodePudding user response:

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

  • Related