Powershell: Space charter displayed as Unicode text

Created on 30 Jun 2020  路  12Comments  路  Source: PowerShell/PowerShell


When typing in pwsh.exe, the space charter is displayed as what I believe is the Unicode code.

Steps to reproduce

Download Powershell core binary archive to a windows machine, extract, run pwsh.exe, and type some commands including a space character. 

Expected behavior

Space character is displayed as an empty space in input.

Actual behavior

鈫怺104m is displayed.

image

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 6.1.7601 Service Pack 1
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

The text is not removable with backspace.
Copying and pasting generates the same problem.
Test-6.29.2020.zip
Open included file in IE.

Issue-Question Resolution-Answered WG-Interactive-PSReadLine

Most helpful comment

Both \e[104m and \e[0;104m should select bright blue as the background color. The difference is that \e[0;104m also resets the foreground color, font weight, underlining, etc. to defaults. But the console in Windows 7 supports neither of these.

All 12 comments

/cc @daxian-dbw for information.

This [104m looks like an escape sequence used for terminal instructions like changing colour of text, e.g. "dotnet" is yellow in your screenshot, so there will be a "change colour to yellow" sequence before it, and a "change colour back to white" after it that get handled by the terminal and not shown as text. This [104m is not being handled correctly and is breaking through where it shouldn't - maybe it's not written quite right.

\e[0;104m is close to it, and would be setting an intense blue background, which you have as the background colour in your screenshot. So maybe that's what it is supposed to say, and has a missing 0; in it, so it's not handled as a colour, and is being printed as text.

Tracking where it's coming from would help; things you could try:

  • Remove-Module PSReadline - does it still happen after that? this enhances the prompt, and is involved in some colour settings. (This will only temporarily remove it, get it back by closing / restarting PowerShell).
  • Get-Module will list running modules; can you share the list? One of them might be causing this.
  • Get-Content $Profile is the scripts running at PowerShell startup, if you have customised it, it might be loading something which affects this.
  • Starting a command prompt, and then running pwsh inside it and seeing if it still happens in a more basic terminal.

the space charter is displayed as what I believe is the Unicode code.

If it was a Unicode space, it would look the same as any other space; Unicode was built so that all the basic English letters, numbers and symbols from American (ASCII) computers would be the same.

The problem only happens when running the executable directly. Changing to the binaries directory in cmd.exe, or powershell.exe, then running pwsh.exe does not give me the problem.

Removing the module PSReadline fixes the problem when running the executable directly.

I will fun the other commands and post the output when I get the time.

Ah, it's a PS Readline thing; are you running Windows 8? I think it's this issue: https://github.com/PowerShell/PSReadLine/issues/1508 and https://github.com/PowerShell/PowerShell/issues/11685

Windows 7.
(We will upgrade to 10 eventually when we get the money. We got most of our computers used after the free upgrade.)

Both \e[104m and \e[0;104m should select bright blue as the background color. The difference is that \e[0;104m also resets the foreground color, font weight, underlining, etc. to defaults. But the console in Windows 7 supports neither of these.

Ok. I will keep the module from loading on startup. I just think it's funny though that running it from a cmd or Windows Powershell session works just fine though. Maybe it's a bug. (Wink.)

Not sure why this was closed.

I have the same problem with latest Pwsh 7.1.0-rc.1 on Win8.1, but with Pwsh 6.1.1 it works fine.

If I remember right, I closed it because their was a workaround, or because it was because PWSH was using a feature not available in Windows 7.
But it has been a long time since I closed it.

If you look at here at the BackgroundColorMap , there is definitely something fishy with the Blue and perhaps the regex handling of AnsiReset = "\x1b[0m"; which can be shorter (as \x1b[m) than the minimum 4 as mentioned in code comments.

https://github.com/PowerShell/PowerShell/issues/11685#issuecomment-711093883

/cc @daxian-dbw for information.

Was this page helpful?
0 / 5 - 0 ratings