Search code examples
character-encodingconsolespecial-characterspaste

Command prompt changing characters in pasted text


I'm writing a C# console application, and whenever I paste text that contains double quotation marks into the console, it changes them to a regular quotation mark.
Here's an example: I paste „Hello World!” into the console, but it displays „Hello World!" instead. I tried changing the input and output enconding to unicode, but it didn't help. Pasting into notepad works just fine.


Solution

  • Found solution for pure cmd window as well as for a console application if run by double click from File Explorer. There is a DWORD value named FilterOnPaste under registry key HKEY_CURRENT_USER\Console. Defaults to 1 (1 enables new paste behavior), change it to 0.

    Check

    reg query HKCU\Console -v FilterOnPaste
    

    and if you get default data

    HKEY_CURRENT_USER\Console
        FilterOnPaste    REG_DWORD    0x1
    

    or ERROR: The system was unable to find the specified registry key or value then run

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

    An explanation at What's New in the Windows Console in Windows Server 2016 => Controlling the new features (valid for Windows 10 console as well).

    Another explanation for a cmd shortcut settings with screenshots at How to enable the new console in Windows 10 and what are its defaults?.

    Actually I can't understand full meaning and consequences of new paste behavior.