Wrong encoding on powershell import-module #12114

Closed
opened 2026-01-31 03:06:37 +00:00 by claunia · 6 comments
Owner

Originally created by @SainoNamkho on GitHub (Jan 19, 2021).

Environment

Windows build number: 10.0.19042.685
Windows Terminal version: 1.4.3243.0

Steps to reproduce

I use oh-my-posh to change the theme.

Set-Theme Material

which uses import-module inside.

Expected behavior

image

Actual behavior

image

The module file is encoded in utf8.

 gc "$home\Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.496\Themes\Material.psm1"

gets

...
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = '+'
$sl.PromptSymbols.HomeSymbol = '馃彔'
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
...

But

 gc "$home\Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.496\Themes\Material.psm1" -encoding utf8

gets
image

Originally created by @SainoNamkho on GitHub (Jan 19, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.19042.685 Windows Terminal version: 1.4.3243.0 ``` # Steps to reproduce I use oh-my-posh to change the theme. ``` Set-Theme Material ``` which uses `import-module` inside. # Expected behavior ![image](https://user-images.githubusercontent.com/23036788/105041220-af290b00-5a9d-11eb-809a-4b657bf67267.png) <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> # Actual behavior ![image](https://user-images.githubusercontent.com/23036788/105040274-99ffac80-5a9c-11eb-9757-29edd099e373.png) <!-- What's actually happening? --> The module file is encoded in utf8. ``` gc "$home\Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.496\Themes\Material.psm1" ``` gets > ... > $sl = $global:ThemeSettings #local settings $sl.PromptSymbols.PromptIndicator = '+' $sl.PromptSymbols.HomeSymbol = '馃彔' $sl.Colors.PromptSymbolColor = [ConsoleColor]::Green $sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue ... But ``` gc "$home\Documents\WindowsPowerShell\Modules\oh-my-posh\2.0.496\Themes\Material.psm1" -encoding utf8 ``` gets ![image](https://user-images.githubusercontent.com/23036788/105041796-66258680-5a9e-11eb-955a-500b4af364a1.png)
claunia added the Needs-TriageNeeds-Tag-FixNeeds-Attention labels 2026-01-31 03:06:37 +00:00
Author
Owner

@DHowett commented on GitHub (Jan 19, 2021):

This is almost certainly going to be a powershell issue. Can you share the output of $PSVersionTable in both VS Code and Terminal?

@DHowett commented on GitHub (Jan 19, 2021): This is almost certainly going to be a powershell issue. Can you share the output of `$PSVersionTable` in both VS Code and Terminal?
Author
Owner

@SainoNamkho commented on GitHub (Jan 19, 2021):

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.610
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.610
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Since they're using the same powershell executable, I illustrated the VSCode case just for an example.
The encoding is correct when I directly run powershell.exe as well as in VSCode integrated terminal, so I wonder if there will be any solution with terminal despite the issue's belongingness to powershell.

@SainoNamkho commented on GitHub (Jan 19, 2021): > $PSVersionTable ``` Name Value ---- ----- PSVersion 5.1.19041.610 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.610 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 ``` Since they're using the same powershell executable, I illustrated the VSCode case just for an example. The encoding is correct when I directly run powershell.exe as well as in VSCode integrated terminal, so I wonder if there will be any solution with terminal despite the issue's belongingness to powershell.
Author
Owner

@DHowett commented on GitHub (Jan 19, 2021):

The encoding is correct when I directly run powershell.exe

This is concerning, because when running in the vintage console (conhost) powershell has no ability to display emoji ...

@DHowett commented on GitHub (Jan 19, 2021): > The encoding is correct when I directly run powershell.exe This is concerning, because when running in the vintage console (conhost) powershell has no ability to display emoji ...
Author
Owner

@DHowett commented on GitHub (Jan 19, 2021):

Can you share the output of the following powershell command?

(gi hkcu:/console),(gci hkcu:\console -rec) | % { gp $_.PSPath CodePage -EA:Ignore }

I wonder if you have a codepage set globally that Terminal is not using?

@DHowett commented on GitHub (Jan 19, 2021): Can you share the output of the following powershell command? ``` (gi hkcu:/console),(gci hkcu:\console -rec) | % { gp $_.PSPath CodePage -EA:Ignore } ``` I wonder if you have a codepage set globally that Terminal is not using?
Author
Owner

@SainoNamkho commented on GitHub (Jan 20, 2021):

Can you share the output of the following powershell command?

(gi hkcu:/console),(gci hkcu:\console -rec) | % { gp $_.PSPath CodePage -EA:Ignore }

I wonder if you have a codepage set globally that Terminal is not using?

Thanks a lot. The default ANSI codepage in terminal was indeed not compliant with the global setting as UTF8.
It's now correct after a reinstall.

@SainoNamkho commented on GitHub (Jan 20, 2021): > Can you share the output of the following powershell command? > > ``` > (gi hkcu:/console),(gci hkcu:\console -rec) | % { gp $_.PSPath CodePage -EA:Ignore } > ``` > > I wonder if you have a codepage set globally that Terminal is not using? Thanks a lot. The default ANSI codepage in terminal was indeed not compliant with the global setting as UTF8. It's now correct after a reinstall.
Author
Owner

@DHowett commented on GitHub (Jan 20, 2021):

Thank you for the info!

@DHowett commented on GitHub (Jan 20, 2021): Thank you for the info!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#12114