PowerShell / PowerShell/vscode-powershell

Integrated Console only sets Console.OutputEncoding to UTF-8, not also Console.InputEncoding

Aperta
#2,816 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Extension Terminal Issue-Bug
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

System Details

System Details Output

### VSCode version: 1.47.2 17299e413d5590b14ab0340ea477cdd86ff13daf x64

### VSCode extensions:
DavidAnson.vscode-markdownlint@0.36.1
fabianlauer.vs-code-xml-format@0.1.5
florianloch.text-transform@0.1.0
formulahendry.code-runner@0.11.0
idleberg.applescript@0.18.2
ms-azure-devops.azure-pipelines@1.170.0
ms-dotnettools.csharp@1.22.1
ms-python.python@2020.7.94776
ms-vscode.azure-account@0.8.11
ms-vscode.cpptools@0.29.0
ms-vscode.powershell@2020.6.0
Shan.code-settings-sync@3.4.3
slevesque.vscode-autohotkey@0.2.2
slevesque.vscode-hexdump@1.7.2
twxs.cmake@0.0.17
vitaliymaz.vscode-svg-previewer@0.5.2


### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.0-preview.5
PSEdition                      Core
GitCommitId                    7.1.0-preview.5
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue Description

Unlike regular console windows (and unlike PowerShell running as a regular shell in the VSCode integrated terminal), the PowerShell Integrated Console sets [console]::OutputEncoding to UTF-8, which causes output from external programs to be interpreted as UTF-8-encoded.

However, it doesn't also set the input encoding, [console]::InputEncoding, which not only makes sense for consistency, but has unwanted side effects:

PowerShell [Core] v6+ itself also defaults to UTF-8 in the $OutputEncoding preference variable, which means that text sent to external programs is sent as UTF-8.

However, not setting [console]::InputEncoding means that external programs that run the chcp utility to infer the active OEM code page still see the system's OEM code page - this could affect how Visual Studio Code's code CLI interprets its stdin input - see https://github.com/PowerShell/PowerShell/issues/13216

Setting [console]::InputEncoding causes chcp to reflect the newly assigned encoding's code page (but note that using chcp itself to change the code page from inside PowerShell doesn't work, because .NET caches the [console] encodings).

Expected Behaviour
PS> chcp
65001  # UTF-8
Actual Behaviour
PS> chcp
437  # e.g., on US-English systems

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Non sono indicati file o test. Individua la configurazione di Integrated Console che assegna Console.OutputEncoding e verifica come vengono inizializzate le codifiche della console. Il lavoro è completato quando anche la codifica di input della console è UTF-8 e l’esecuzione di chcp in Integrated Console restituisce la code page 65001, senza modificare la codifica tramite chcp stesso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, typescript
Ambito
cli, developer-experience
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.