# encoding: ascii
# api: powershell
# title: PowerShell_ISE Profile
# description: Here is a Microsoft.PowerShellISE_profile.ps1 that causes PowerShell_ISE to save all files in ASCII encoding instead of Unicode Big Endian. Adapted from Oisin Grehan’s script at http://www.nivot.org/nivot2/post/2010/05/21/PowerShellISEHackingChangeDefaultSaveEncodingToASCII.aspx#comment.
# version: 0.1
# author: Richard Vantreas
# license: CC0
# x-poshcode-id: 3000
# x-archived: 2012-01-14T07:06:15
# x-published: 2012-10-12T21:02:00
#
#
#--------------------------------------------------------------------------------------------------------------
#Convert Untitled1.ps1 to ASCII encoding
$psise.CurrentPowerShellTab.Files | % {
# set private field which holds default encoding to ASCII
$_.gettype().getfield("encoding","nonpublic,instance").setvalue($_, [text.encoding]::ascii)
}
# watch for changes to the Files collection of the current Tab
register-objectevent $psise.CurrentPowerShellTab.Files collectionchanged -action {
# iterate ISEFile objects
$event.sender | % {
# set private field which holds default encoding to ASCII
$_.gettype().getfield("encoding","nonpublic,instance").setvalue($_, [text.encoding]::ascii)
}
}
#--------------------------------------------------------------------------------------------------------------