You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Windows Terminal] Console.KeyAvailable causes the next Unicode character input 'EN DASH' to be skipped in console #38966
When pasting text with Unicode character in it to console on Windows (conhost) using right click, the Unicode character, such as the 'EN DASH' character in the following example
New-StoragePool –FriendlyName
will somehow be skipped and missing from the Console.ReadKey(true) calls. More investigation shows the call to Console.KeyAvailable could be the culprit -- when Console.KeyAvailable is not in use, Console.ReadKey(true) is able to receive the 'EN DASH' character just fine.
Repro code
usingSystem;namespaceconsole{publicclassProgram{staticvoidMain(string[]args){do{if(Console.KeyAvailable){varkey=Console.ReadKey(true);Print(key);}else{varkey=Console.ReadKey(true);Print(key);}}while(true);}// Print the decimal value of `KeyChar`, the `ConsoleKey` and `Modifiers` values.privatestaticvoidPrint(ConsoleKeyInfokey){Console.Write('[');Console.Write((int)key.KeyChar);Console.Write($" {key.Key}{key.Modifiers}");Console.Write(']');}}}
Copy the text "l –F", and then right click to paste the text, you will see that the 'EN DASH' character is missing:
Then, copy the text "–F" with the 'EN DASH' character being the first character, so Console.KeyAvailable will not run before accepting that character, then Console.Readkey(true) is able to receive that Unicode character ():
Additional information
Please note that, the same issue happens in .NET 5 preview as well.
If I change the Main method above to be the following, then Console.Readkey can always receive the Unicode character.
But I have to use Console.KeyAvailable in my project together with Console.ReadKey, and hence cannot receive the Unicode when user is pasting by right click in console.
@eiriktsarpalis Thanks for looking into this!
Please try out the repro from cmd.exe. I don't know why it works in PowerShell, but it repros consistently when running it from cmd.exe. Below is a screen gif of it when I paste "l –F" with right clicking. The input/output encoding's are the defaults:
@eiriktsarpalis I found the OutputEncoding may plays a role here. I added Console.OutputEncoding = Encoding.UTF8 below to the original repro code, and now I can reproduce the issue in both cmd.exe and powershell core.
@eiriktsarpalis Additional data point: I found this only reproduce in Windows Terminal. If I do the same in the conhost, then the 'EN DASH' character can always be captured as [45 OemMinus 0], no matter launching console.exe from cmd.exe, or PowerShell core, or Windows PowerShell. Also, I tried on a second machine and it's the same behavior.
So a side question: why the 'EN DASH' character results in different ConsoleKeyInfo in Windows Terminal vs. conhost?
I'm reproducing the same behaviour. Basically the character is omitted on Windows terminal only (reproducing with either cmd, PowerShell or Git Bash), but not on any other terminal emulators that I tested. It namely works for Visual Studio Console, Git bash, Powershell classic and ConEmu. I'll update the issue description accordingly.
changed the title [-]`Console.KeyAvailable` causes the next Unicode character input 'EN DASH' to be skipped in console[/-][+][Windows Terminal] `Console.KeyAvailable` causes the next Unicode character input 'EN DASH' to be skipped in console[/+]on Jul 23, 2020
I've noticed the same problem. Similarly, if you call Console.KeyAvailable, certain characters will be skipped. This occurred when I pasted a string containing 'KATAKANA MIDDLE DOT' into the console as shown below.
A・B
Oddly enough, it didn't happen in the Windows Terminal, but seemed to happen in the command prompt.
I've marked this issue with help wanted label. The person who is willing to work on it should take one of the provided repro apps and debug the code pointed by @msftrncs in #38966 (comment) If that is the source of the problem, please send a PR with a fix.
Activity
eiriktsarpalis commentedon Jul 20, 2020
Hi @daxian-dbw
I tried your reproduction locally, but couldn't reproduce the issue. This is what I get on the powershell terminal:

And this is what I see using powershell core on Windows terminal:
This is using .NET Core 3.1.302, but the behaviour is similar in .NET 5 preview.
daxian-dbw commentedon Jul 21, 2020
@eiriktsarpalis Thanks for looking into this!
Please try out the repro from cmd.exe. I don't know why it works in PowerShell, but it repros consistently when running it from cmd.exe. Below is a screen gif of it when I paste "l –F" with right clicking. The input/output encoding's are the defaults:
eiriktsarpalis commentedon Jul 22, 2020
I'm still not reproducing :/
@daxian-dbw are you able to reproduce on a second machine?
@adamsitnik when you get back, would you be able to try and reproduce locally?
daxian-dbw commentedon Jul 22, 2020
@eiriktsarpalis I found the OutputEncoding may plays a role here. I added
Console.OutputEncoding = Encoding.UTF8below to the original repro code, and now I can reproduce the issue in both cmd.exe and powershell core.Run from cmd.exe
paste "l –F" by right clicking:
paste "–F" with the 'EN DASH' character being the first character by right clicking:
Run from powershell core
paste "l –F" by right clicking:
paste "–F" with the 'EN DASH' character being the first character by right clicking:
daxian-dbw commentedon Jul 22, 2020
@eiriktsarpalis Additional data point: I found this only reproduce in Windows Terminal. If I do the same in the conhost, then the 'EN DASH' character can always be captured as
[45 OemMinus 0], no matter launchingconsole.exefrom cmd.exe, or PowerShell core, or Windows PowerShell. Also, I tried on a second machine and it's the same behavior.So a side question: why the 'EN DASH' character results in different
ConsoleKeyInfoin Windows Terminal vs. conhost?eiriktsarpalis commentedon Jul 23, 2020
I'm reproducing the same behaviour. Basically the character is omitted on Windows terminal only (reproducing with either cmd, PowerShell or Git Bash), but not on any other terminal emulators that I tested. It namely works for Visual Studio Console, Git bash, Powershell classic and ConEmu. I'll update the issue description accordingly.
[-]`Console.KeyAvailable` causes the next Unicode character input 'EN DASH' to be skipped in console[/-][+][Windows Terminal] `Console.KeyAvailable` causes the next Unicode character input 'EN DASH' to be skipped in console[/+]eiriktsarpalis commentedon Jul 23, 2020
Also, the issue does not reproduce when using Windows terminal on WSL.
daxian-dbw commentedon Jul 26, 2020
It would be very helpful if @DHowett can share some insight, especially on this question:
Thanks in advance @DHowett!
msftrncs commentedon Feb 3, 2021
This looks like a potential problem area.
runtime/src/libraries/System.Console/src/System/ConsolePal.Windows.cs
Lines 285 to 296 in d1c0fa8
Could it be possible that these characters are not triggering IsKeyDownEvent and this loop is eating them?
shibayan commentedon Aug 7, 2021
I've noticed the same problem. Similarly, if you call
Console.KeyAvailable, certain characters will be skipped. This occurred when I pasted a string containing 'KATAKANA MIDDLE DOT' into the console as shown below.Oddly enough, it didn't happen in the Windows Terminal, but seemed to happen in the command prompt.
Repro code
Use
Console.KeyAvailablepaste "A・B" by right clicking:
Not use
paste "A・B" by right clicking:
adamsitnik commentedon Nov 14, 2023
I've marked this issue with
help wantedlabel. The person who is willing to work on it should take one of the provided repro apps and debug the code pointed by @msftrncs in #38966 (comment) If that is the source of the problem, please send a PR with a fix.esperecyan commentedon Oct 21, 2025
Observed
●,★,■vanish.★alone does not vanish, but"★"becomes""(the inner symbol is dropped).Where it reproduced / did not reproduce
Shell extras