PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Read-Host replaces EM-Dash inconsistent behavior

Open Ross-Murphy opened this issue 3 years ago • 6 comments

Prerequisites

Steps to reproduce

I am using Read-Host to gather user input.

If the user inputs a string with an EM dash such as "user input with a — inside" read-host acts differently depending on how pwsh is run and replaces em dash with en dash in some cases.

Where it works: pwsh in WS2, PowerShell in Windows Terminal or the PowerShell Extension in VScode all work as expected.

What's not working as expected: On Windows 10 when run from the window titled pwsh.exe

Reproduce this by:

  • starting pwsh.exe from the start menu
  • type read-host in the window provided.
  • copy and then paste in string with em dash such as this "user input with a — inside"
  • Returned string has en dash like this "user input with a - inside"

pwsh in WS2, PowerShell in Windows Terminal or the PowerShell Extension in VScode all work as expected and the em dash is maintained.

There is a similar issue listed here but it has gone off into the weeds of file names etc. and is missing the main issue with read-host imo. https://github.com/PowerShell/PowerShell/issues/18110
I suspect this has to do with a variance in readline methods

Expected behavior

pwsh in WSL2, PowerShell in Windows Terminal or the PowerShell Extension in VScode all work as expected and the em dash " — " is maintained and not converted to " - " en dash.

PS /var/log> read-host
user input with a — inside
user input with a — inside

Actual behavior

Unexpected Behavior: The em-dash immediately is converted to an en dash '-' even before hitting enter to submit.


PS C:\Users> read-host
user input with a - inside
user input with a - inside

Error details

No error.

Environment data


 Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name                           Value
----                           -----
PSVersion                      7.3.4
PSEdition                      Core
GitCommitId                    7.3.4
OS                             Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Ross-Murphy avatar Jun 14 '23 21:06 Ross-Murphy

I think this might be a conhost issue. I'm getting the same behavior from Windows PowerShell and Command Prompt in conhost.

dwtaber avatar Jun 14 '23 21:06 dwtaber

@Ross-Murphy, on a technical note, what your — (EM DASH, U+2014) turns into isn't an – (EN DASH, U+2013), it is an ASCII-range - (HYPHEN-MINUS, U+002D)

@dwtaber, I agree that it is related to the console host (regular console windows provided by conhost.exe), but I do see different behavior in PowerShell vs. cmd.exe (Command Prompt), and the problem seems to go away if you start PowerShell via cmd.exe

If you run the following in any PowerShell console / terminal and paste when prompted, whether or not the problem occurs will be visually obvious:

$c = [char] 0x2014; "An em dash looks like this:    $c"
$c | Set-Clipboard
Read-Host 'Paste what''s on the clipboard'

mklement0 avatar Jun 14 '23 22:06 mklement0

Where it works: pwsh in WS2, PowerShell in Windows Terminal or the PowerShell Extension in VScode all work as expected.

What's not working as expected: On Windows 10 when run from the window titled pwsh.exe

Perhaps @DHowett could explain the behavior.

iSazonov avatar Jun 15 '23 04:06 iSazonov

the WG discussed this and while we believe that the issue is likely in conhost.exe, we agree that further investigation is needed determine what differences occur in the various scenarios above.

JamesWTruher avatar Jun 28 '23 20:06 JamesWTruher

I wonder if anyone could provide guidance on how to move this issue along or get it into the proper queue?

Ross-Murphy avatar Dec 27 '23 18:12 Ross-Murphy

This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.