-
-
Save xoner/4671514 to your computer and use it in GitHub Desktop.
$OutputEncoding = New-Object -typename System.Text.UTF8Encoding | |
[Console]::OutputEncoding = New-Object -typename System.Text.UTF8Encoding |
"$OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8"
This works...
Add
$env:LC_ALL='C.UTF-8'
to your$profile
.
👍
"$OutputEncoding = [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8" works for me.
I have tried:
- "$PSDefaultParameterValues = @{'Out-File:Encoding' = 'utf8'}" didn't work
- "$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'" didn't work.
[Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
God bless your soul!
$PSDefaultParameterValues['Out-File:Encoding'] = 'utf8'
worked for me for PowerShell 5.1, as per this doc
Ended up using $PSDefaultParameterValues['*:Encoding'] = 'utf8'
to set utf-8 to "to change the default encoding for all cmdlets that have the Encoding parameter". Also put it in the $profile
file for persistence.
You can also add [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
to the start of your powershell profile script.
Notepad $profile
If the file doesn't exist, create one
add [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
as the first line of the file`
save
restart powershell
Add
$env:LC_ALL='C.UTF-8'
to your$profile
.