winget-cli
winget-cli copied to clipboard
Code page isn't being set correctly when piping commands
Brief description of your issue
By default the code page on Windows for en-US devices is 437 (OEM - United States)
but when running winget search tencent | sort
it automatically switches the code page to 65001 (UTF-8)
and then switches the code page back to 437 (OEM - United States)
^ This isn't an issue here because the same happens to winget search
and winget list
but when piping the winget search
command to | sort
or | find
it displays corrupted characters until the code page is permanently set to 65001 (UTF-8)
.
Perhaps it's switching the code page back to 437 (OEM - United States)
halfway through?
I am using Windows Terminal Preview here because Command Prompt doesn't support all of the special characters shown in winget search
.
Steps to reproduce
- Clean install the latest Dev Channel build of Windows 11 on Hyper-V from ISO or VHDX.
- Make sure the latest Microsoft Store application updates are installed so you can receive the latest App Installer build. If not, you will likely need to go to Settings > Windows Update > Windows Insider Program > Choose your Insider settings and pick Dev; or pick Canary or Selfhost under Custom Options.
-
winget source update
-
winget search | sort
Expected behavior
-
chcp 65001
- permanently set code page to UTF-8 -
winget source update
-
winget search tencent | sort
Notice how there's no corrupted characters shown.
Actual behavior
-
winget source update
-
winget search tencent | sort
Notice how there's corrupted characters shown.
Environment
Windows Package Manager (Preview) v1.3.1661-preview
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.25140.1000
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.1661.0
Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
Links
---------------------------------------------------------------------------
Privacy Statement https://aka.ms/winget-privacy
License Agreement https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
Any other software?
- Windows Terminal Preview version 1.14.1452.0
- Windows Package Manager Source (winget) version 2022.620.1418.424
- Git version 2.37.0.rc1.windows.1
This issue is a duplicate of the now closed https://github.com/microsoft/winget-cli/issues/1331 and was mentioned in https://github.com/microsoft/winget-cli/issues/1300.
@ItzLevvie, I'm digging through some of the older issues now that WinGet 1.4 is out. I'm not sure if this is actually a bug in WinGet or something else. I'd like to get it routed to the correct team. I ran across something very similar which leads me to believe that piping the output is causing the trouble here. It might even be related to this Issue at PowerShell.
We've been doing work on native PowerShell and had to structure the objects a bit differently to get sorting behavior to work as expected.
@ItzLevvie this issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.