I tried running this:
(Get-Content c:\example.srt).replace('æ', 'ć') | Set-Content c:\example.srt
But it only replaces the character æ
with ANSI c
.
I'd also like to be able to replace more than 1 character at the time.
I tried running this:
(Get-Content c:\example.srt).replace('æ', 'ć') | Set-Content c:\example.srt
But it only replaces the character æ
with ANSI c
.
I'd also like to be able to replace more than 1 character at the time.
You can do like this:
Replace them in the character group.Put the symbols in the character group.
Get-Content c:\example.srt |% {$_ -replace "[æ\._\.*]", "ć"}
It will replace æ
, _
, *
with ć
.
like:
Get-Date -Format G | foreach {$_ -replace "[:\./]", "_"}
Hope it helps.
You can give this a go. It converts a file from Windows-1252 to UTF-8.
$ansi = [System.Text.Encoding]::GetEncoding(1252)
Get-Content -Encoding $ansi "c:\example.srt" | Out-File -Encoding UTF-8 "c:\example.srt"