简体   繁体   English

Linux,bash中的C#Net Core 2.0 Console.ReadLine()

[英]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... вавф 您能告诉我如何解决此问题吗:我通过终端(sudo dotnet run --configuration Release)运行控制台应用程序,并且需要在其中输入键盘文本(Console.ReadLine()),但是在键入时,我得到...вавф...

    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. 使用编码-Unicode。

PS I need some input and output support for Latin and Cyrillic PS我需要对拉丁和西里尔字母的一些输入和输出支持

Most Linux distributions use UTF-8 encoding by default. 大多数Linux发行版默认使用UTF-8编码。 While UTF-8 is a Unicode encoding, it is not the one meant by Encoding.Unicode - that means UTF-16. 而UTF-8 Unicode编码,它不是一个接意味着Encoding.Unicode -这意味着UTF-16。

Try Encoding.UTF8 . 尝试Encoding.UTF8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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