PoshCode Archive  Artifact [e4380461b1]

Artifact e4380461b1856f68be9ebd7e99faccb9f9f72c8e52323bf2733bef0b162ce8e6:

  • File PowerShell_ISE-Profile.ps1 — part of check-in [06e3380fdf] at 2018-06-10 13:18:33 on branch trunk — 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. (user: Richard Vantreas size: 1406)

# 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) 
    } 
}
#--------------------------------------------------------------------------------------------------------------