When saving a new file using PowerShell’s ISE it encodes it as Unicode. For existing files the encoding is not changed.
Some editors and viewers are unable to display files with this encoding.
It is a bug and won’t be fixed in time for Windows 7 RTM.
Workarounds
Open the file in a another editor, do a file save as look for the encoding options and choose ANSI.
Another option, execute this in the command pane
$psISE.CurrentFile.Save([Text.Encoding]::ASCII)
It will save/resave the file with this encoding going forward.
I’ve added this to my ISE profile so the command is easily accessed from the ISE menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Save File ASCII",{$psISE.CurrentFile.Save([Text.Encoding]::ASCII)}, $null) | out-null
{ 2 comments… read them below or add one }
Thanks doug for that hint.
May I add that western european users might prefer
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(”Save File ANSI”,{$psISE.CurrentFile.Save([Text.Encoding]::default)}, $null) | out-null
That works perfectly for me on a german system. We are not very happy with the pure 7-bit ASCII encoding.
Bernd
Thanks dough, great hint.
As german I prefer
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add(”Save File ANSI”,{$psISE.CurrentFile.Save([Text.Encoding]::default)}, $null) | out-null
since here 7-bit ASCII encoding is rather useless.
Bernd