oh-my-posh: Path encoding problem on chinese charactor.
Prerequisites
- I have read and understand the
CONTRIBUTINGguide - I looked for duplicate issues before submitting this one
Description
Path encoding problem on Set-PoshPrompt.
&: The term 'C:\Users\sheey\OneDrive\鏂囨。\PowerShell\Modules\oh-my-posh\3.120.1\bin\posh-windows-amd64.exe'
is not recognized as a name of a cmdlet, function, script file, or executable program.
The string 鏂囨。 should be 文档, or Document in English.
Environment
- Oh my Posh version:
3.120.1 - Theme: haven’t set yet
- Operating System:
Windows 10 - Shell:
pwsh - Terminal:
windows-terminal
Steps to Reproduce
Set-PoshPrompt -Theme agnosterplus
Expected behavior: Set theme.
Actual behavior: Got error.
I changed oh-my-posh.psm1 to see if it’s the pwsh has wrong encoding.
# near line 59
$poshCommand = Get-PoshCommand
Write-Output $poshCommand # I added this to print the path
Invoke-Expression (& $poshCommand --init --shell=pwsh --config="$config")
but it displayed characters correctly.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (8 by maintainers)
Commits related to this issue
- feat: remove forced UTF8 relates to #576 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 2 years ago
- feat: remove forced UTF8 relates to #576 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 2 years ago
- feat: remove forced UTF8 relates to #576 — committed to JanDeDobbeleer/oh-my-posh by JanDeDobbeleer 2 years ago
I solved it by setting Windows encoding to UTF8. See stackoverflow.
It passed a quick test on a fresh Chinese VM.
Thanks @JanDeDobbeleer!
@gerardog oh my. Thank you so much for this!
@gerardog allow me to do some tests, it’s been a while and
conhostalso went through some changes. If it works on my machines, I’ll do as proposed because I agree, we shouldn’t have to do this.Hi Jan. I had some encoding issues with
pwshwhich lead me to force utf-8 on gerardog/gsudo. I found out that:Ultimately found out it was not
pwshbut oh-my-posh who was changing the encoding. I’ve capturedoh-my-posh --print-initand put that literal into my $profile without the encoding. I saw oh-my-posh fully functional when using a proper font. I understand there must be other issues if you don’t change the encoding. But at least my take on it is that it should be the user who changes the encoding knowingly and probably do it in a full user scope, given that if one process changes the encoding, it also changes the code page for the current console, even if you close PowerShell.In that direction, what about adding a setting to disable any encoding change ? Something the user could put in their profiles before oh-my-posh, like…
Thanks, and great work with oh-my-posh. I Love it and use it everyday.
I have same problem and @Sheey11 's method also works for me.
I had the same problem with
Set-PoshPrompton a Danish laptop withØin the posh path. Solved by changing to beta UTF-8 mode as per the SO link from @Sheey11 .