c# - ReadLine 吃掉波浪号

标签 c# console readline

当我注意到一些奇怪的事情时,我正在为我正在做的工作做一个小测试程序。获取以下代码片段:

string words;
while ((words = Console.ReadLine()) != "quit")
{
    Console.WriteLine(words);
}

如果我用波浪号输入任何内容,它就会被吃掉。因此,如果我输入 ação,它会写回 ação

谁能解释一下为什么?所有其他口音都可以。

最佳答案

似乎是编码问题,请尝试将输入/输出编码更改为 unicode:

Console.InputEncoding = Encoding.Unicode;
Console.OutputEncoding = Encoding.Unicode;
string words;
while ((words = Console.ReadLine()) != "quit")
{
    Console.WriteLine(words);
}

关于c# - ReadLine 吃掉波浪号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32349659/

相关文章:

c# - CellContentClick 事件并不总是有效

c# - nHibernate 更新什么都不做

c++ - 禁用来自外部程序的控制台输出 (C++)

c# - 使用 LINQ 进行简单的 XML 解析

linux - 哪些可能的原因会阻止 Linux 上的虚拟终端?

python - 是否有与 HighLine 等效的 Python?

c# - 从 Amazon s3 流中读取文本

asp-classic - ASP Readline 非标准行尾

node.js - Nodejs 使用 readline 时暂停

c# - 我是否需要 iOS 或 Android 设备才能使用 Visual Studio 和 Xamarin 编写应用程序