Dienstag, 3. November 2009


Just had to work with some data in utf-8 without BOM. I want to extend this to OEM-850 later, but here the first draft.

And if you are really using ISE for productive things please send me (bernd_k) a note at twitter.

Sometimes I believe I'm the only one. At least in https://twitter.com/bernd_k/ise-users. I want to add you.

Feedback will improve my presentation. Otherwise you get it quick and dirty.

The function Add-IseMenu is in ISEpack http://code.msdn.microsoft.com/PowerShellPack.

Have fun with ISE


function Reload-ISE ($encoding = 'UTF8')

# ToDo OEM 850 requires .NET
# Get-Content Encodings: Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, Ascii

$path = $psise.CurrentFile
# $path
$fullpath = $path.FullPath
# $fullpath
$text = Get-Content -Encoding $encoding $fullpath -ReadCount 0 -totalcount -1

$text = $text -join "`r`n"

# $count = $psise.CurrentPowerShellTab.Files.count
# $psIse.CurrentPowerShellTab.Files.Add()
# $Newfile = $psIse.CurrentPowerShellTab.Files[$count]
# $Newfile.Editor.Text = $text

$psise.CurrentFile.Editor.Text = $text

Add-IseMenu -name 'Reload' @{
"String" = {Reload-ISE "String"}
"UTF8" = {Reload-ISE "UTF8"}
"UTF7" = {Reload-ISE "UTF7"}
"Ascii" = {Reload-ISE "Ascii"}
"Unicode" = {Reload-ISE "Unicode"}
"BigEndianUnicode" = {Reload-ISE "BigEndianUnicode"}
#"OEM850" = {Reload-ISE "OEM850"}

Keine Kommentare:

Kommentar veröffentlichen