fix(pwsh): force console to UTF-8 from module

This commit is contained in:
Jan De Dobbeleer 2021-12-27 13:23:06 +01:00 committed by Jan De Dobbeleer
parent af639a2b7b
commit 5d1cd6209a
2 changed files with 13 additions and 1 deletions

View file

@ -2,6 +2,18 @@ $env:POSH_PATH = "$((Get-Item $MyInvocation.MyCommand.ScriptBlock.Module.ModuleB
$env:POSH_THEMES_PATH = $env:POSH_PATH + "/themes"
$env:PATH = $env:POSH_PATH + [System.IO.Path]::PathSeparator + $env:PATH
if ($ExecutionContext.SessionState.LanguageMode -ne "ConstrainedLanguage") {
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
}
else {
Write-Host "[WARNING] ConstrainedLanguage mode detected, unable to set console to UTF-8.
When using PowerShell in ConstrainedLanguage mode, please set the
console mode manually to UTF-8. See here for more information:
https://ohmyposh.dev/docs/faq#powershell-running-in-constrainedlanguage-mode
"
$env:POSH_CONSTRAINED_LANGUAGE_MODE = $true
}
function Get-PoshDownloadUrl {
param(
[Parameter(Mandatory = $true)]

View file

@ -3,7 +3,7 @@
if ($ExecutionContext.SessionState.LanguageMode -ne "ConstrainedLanguage") {
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
}
else {
elseif ($env:POSH_CONSTRAINED_LANGUAGE_MODE -ne $true){
Write-Host "[WARNING] ConstrainedLanguage mode detected, unable to set console to UTF-8.
When using PowerShell in ConstrainedLanguage mode, please set the
console mode manually to UTF-8. See here for more information: