Created
July 12, 2017 04:56
-
-
Save g3rhard/407879c8d2c41f680835030be5481e61 to your computer and use it in GitHub Desktop.
Конвертация вывода программы в Powershell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Script by xaegr (https://xaegr.wordpress.com/2007/01/24/decoder/) | |
#usage: | |
# Get-Content notes.txt | ConvertTo-Encoding "windows-1251" "koi8-r" | Set-Content decoded.txt | |
# command | ConvertTo-Encoding cp866 windows-1251 | |
function ConvertTo-Encoding ([string]$From, [string]$To){ | |
Begin{ | |
$encFrom = [System.Text.Encoding]::GetEncoding($from) | |
$encTo = [System.Text.Encoding]::GetEncoding($to) | |
} | |
Process{ | |
$bytes = $encTo.GetBytes($_) | |
$bytes = [System.Text.Encoding]::Convert($encFrom, $encTo, $bytes) | |
$encTo.GetString($bytes) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment