简体   繁体   中英

C# Net core 2.0 Console.ReadLine() in Linux, bash

Can you please tell me how to fix this problem: I run the console application through the terminal (sudo dotnet run --configuration Release) and in it i need to enter text from the keyboard (Console.ReadLine()), but when typing, I get... вавф

    static void Main(string[] args)
    {
        Console.OutputEncoding = Encoding.Unicode;
        Console.InputEncoding = Encoding.Unicode;

        string test = Console.ReadLine();
    }

Also I tried to run the application in screen. The encoding is used - Unicode.

PS I need some input and output support for Latin and Cyrillic

Most Linux distributions use UTF-8 encoding by default. While UTF-8 is a Unicode encoding, it is not the one meant by Encoding.Unicode - that means UTF-16.

Try Encoding.UTF8 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM