4. Januar 2017 17:35
$targetEncoding = New-Object System.Text.UnicodeEncoding($false,$false)
$targetEncoding = New-Object System.Text.UnicodeEncoding($false,$false,$true)
Function Convert_OEM850_UTF16LENOBOM
{
$args = resolve-path $args
$WorkingFolder = Split-Path -Parent $args
$sourceEncoding = [System.Text.Encoding]::GetEncoding(850)
# Litte Endian, no BOM
$targetEncoding = New-Object System.Text.UnicodeEncoding($false,$false)
$convertedFileName = [System.IO.Path]::GetFileNameWithoutExtension($args) +"_UTF16LE" + [System.IO.Path]::GetExtension($args)
$convertedfile = New-Item -path "$WorkingFolder\$convertedFileName" -type file
$textfile = [System.IO.File]::ReadAllText($args, $sourceencoding)
[System.IO.File]::WriteAllText($convertedfile, $textfile, $targetencoding)
Write-host $args 'converted to' $convertedFileName
}
Function Convert_OEM850_UTF16LEBOM
{
$args = resolve-path $args
$WorkingFolder = Split-Path -Parent $args
$sourceEncoding = [System.Text.Encoding]::GetEncoding(850)
# Litte Endian, with BOM
$targetEncoding = New-Object System.Text.UnicodeEncoding($false,$true)
$convertedFileName = [System.IO.Path]::GetFileNameWithoutExtension($args) +"_UTF16LEBOM" + [System.IO.Path]::GetExtension($args)
$convertedfile = New-Item -path "$WorkingFolder\$convertedFileName" -type file
$textfile = [System.IO.File]::ReadAllText($args, $sourceencoding)
[System.IO.File]::WriteAllText($convertedfile, $textfile, $targetencoding)
Write-host $args 'converted to' $convertedFileName
}
23. Januar 2017 13:44
Function Exchange_OEM850_UTF16LENOBOM
{
$args = resolve-path $args
$WorkingFolder = Split-Path -Parent $args
$sourceEncoding = [System.Text.Encoding]::GetEncoding(850)
# Litte Endian, no BOM
$targetEncoding = New-Object System.Text.UnicodeEncoding($false,$false)
$textfile = [System.IO.File]::ReadAllText($args, $sourceencoding)
[System.IO.File]::WriteAllText($args, $textfile, $targetencoding)
Write-host $args 'converted from OEM850 to UTF16LE without BOM'
}