Open patrick330602 opened 3 years ago
That's definitely unexpected - which code page are you coming from and changing to?
That's definitely unexpected - which code page are you coming from and changing to?
This issue in my case exists when switching from/to the code page 932, and from my test, the issue does not exist for codepage 437
Can you run gcm chcp -all
from powershell?
Two points:
chcp 932
to file? What does Format-Hex
on that file tell you?Try alternate ways to set the console I/O code pages:
mode.com con cp select=932
PowerShell:
[console]::OutputEncoding = [System.Text.Encoding]::GetEncoding(932)
[console]::InputEncoding = [System.Text.Encoding]::GetEncoding(932)
PSReadLine in PowerShell 7.1 has odd behavior in this case. It enables the configured output code page only when enter is pressed to run an internal or external command. When control is returned to PSReadLine, it resets the output code page to UTF-8 (65001). This causes the screen to be re-displayed for every line of input, even if just for a brief flash when enter is pressed for an empty line. Revert to normal behavior by unloading it: Remove-Module PSReadLine
.
Python:
py -c "import ctypes; ctypes.WinDLL('kernel32').SetConsoleOutputCP(932)"
py -c "import ctypes; ctypes.WinDLL('kernel32').SetConsoleCP(932)"
Two points:
- Does it matter what is on screen at the time? Is it mainly kana/kanji? Or English characters? A mixture of both?
It's just only English
- What is in the output file when you redirect the output of
chcp 932
to file? What doesFormat-Hex
on that file tell you?
It just says "Active code page: 932".
The Format-Hex
result is:
Path: C:\Users\patrick\a
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 FF FE 41 00 63 00 74 00 69 00 76 00 65 00 20 00 .รพA.c.t.i.v.e. .
00000010 63 00 6F 00 64 00 65 00 20 00 70 00 61 00 67 00 c.o.d.e. .p.a.g.
00000020 65 00 3A 00 20 00 39 00 33 00 32 00 0D 00 0A 00 e.:. .9.3.2.....
Try alternate ways to set the console I/O code pages:
mode.com con cp select=932
This one has a similar behavior of clearing the terminal screen.
Also since I try to use it as a workaround for a PowerShell issue on WSL, the PowerShell method and Python method are not suitable for me...
Also since I try to use it as a workaround for a PowerShell issue on WSL
Are you running CMD or PowerShell from WSL, and do you only experience the bug in that case? WSL executes a Windows console application such as cmd.exe in a conpty session, which may be an important detail, if you don't experience the same problem when running chcp.com from a regular console session.
It's also important to discover whether something other than SetConsoleOutputCP(932)
in "chcp.com" or "mode.com" is clearing the screen, since both are based on ulib.dll for their user interface. Can you build a small program in C that just calls SetConsoleOutputCP(932)
?
Also since I try to use it as a workaround for a PowerShell issue on WSL
Are you running CMD or PowerShell from WSL, and do you only experience the bug in that case? WSL executes a Windows console application such as cmd.exe in a conpty session, which may be an important detail, if you don't experience the same problem when running chcp.com from a regular console session.
Executing chcp.com <different code page>
in PowerShell/cmd/WSL directly from old conhost.exe or Windows Terminal all result in the terminal clear behavior.
It's also important to discover whether something other than
SetConsoleOutputCP(932)
in "chcp.com" or "mode.com" is clearing the screen, since both are based on ulib.dll for their user interface. Can you build a small program in C that just callsSetConsoleOutputCP(932)
?
Thanks for the suggestion. I will try and look whether it solves the issue.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Part of the problem here is reproducing it. This does not happen as described for me, and I suspect that the Microsoft people are in the same boat. It has happened for this person for example, but there's not enough information there for people who do not experience this to reproduce it.
Hmm, then here is the complete language setup: Country/Region: Hong Kong Regional Format: English (Hong Kong SAR) Windows Display: English (Hong Kong SAR) Apps and Websites: English (Hong Kong SAR) Keyboard: English (Hong Kong SAR) - US Current language for non-Unicode programs: Japanese (Japan), Beta UTF-8 support not enabled
Okay, here's one more weird question. If you just run mode.com
, what do you see?
@DHowett
This is the result:
Status for device CON:
----------------------
Lines: 30
Columns: 120
Keyboard rate: 31
Keyboard delay: 1
Code page: 932
We've got this crazy thought that this might be related to the font for some reason.
HKCU\Console
, change the extension to .txt and paste it here/?
I'm wondering if the reason we're not seeing this is there's some change in font that's occurring, which is triggering a clear?
Also quick confirm if you're still seeing this on whatever your latest Windows build and Terminal version? Sorry it's been so long ๐ฌ
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
I just check it today, the problem still exists, and find some more information possinly related to the bug: if I use Japanese as the language for non-Unicode program the problem will show up, but using English do not have this issue it seems.
Also the content requested are here: https://git.pigeons.cloud/-/snippets/1
Removed "Needs-Attention". Someone on the team will take a closer look at this. Adding to current milestone so that we take time to investigate it. :)
Environment
Steps to reproduce
chcp.com <different code page>
in PowerShell/cmd/WSL from oldconhost.exe
or Windows TerminalExpected behavior
It should print out the current code page without clearing the terminal
Actual behavior
It will clear the terminal screen and then print out the current code page.
Other
I also reported the bug in Feedback Hub in case this is not the proper place to report it: https://aka.ms/AAbh6ni