C#控制台更改粘贴文本中的字符

问题描述 投票:0回答:1

我正在编写C#控制台应用程序,每当我将包含双引号的文本粘贴到控制台中时,它都会将它们更改为常规引号。这是一个例子:我将„Hello World!”粘贴到控制台中,但显示为„Hello World!"。我尝试根据unicode更改输入和输出,但这没有帮助。粘贴到记事本中就可以了。

character-encoding console special-characters paste
1个回答
1
投票

为纯cmd窗口以及控制台应用程序找到的解决方案,如果通过从文件资源管理器双击运行。有一个DWORD值在注册表项FilterOnPaste下命名为HKEY_CURRENT_USER\Console。默认为1(1 启用新粘贴行为),将其更改为0

检查

reg query HKCU\Console -v FilterOnPaste

并且如果您获得默认数据

HKEY_CURRENT_USER\Console
    FilterOnPaste    REG_DWORD    0x1

错误:系统无法找到指定的注册表项或值,然后运行

reg add HKCU\Console -v FilterOnPaste -d 0 -t REG_DWORD -f
The operation completed successfully.

What's New in the Windows Console in Windows Server 2016 => Controlling the new features的说明(也对Windows 10控制台有效)。

cmd快捷方式设置的另一种说明,并在How to enable the new console in Windows 10 and what are its defaults?处提供了屏幕截图。

实际上我不理解新粘贴行为的全部含义和后果。

© www.soinside.com 2019 - 2024. All rights reserved.