Similar Posts

Subscribe
Notify of
5 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Erzesel
1 year ago

@’s solution is true, but not really nice…

Up to Powershell 5.1(Windows standard simply the .PS1 (script file) in the editor as UTF-8 with BOM save, then Powershell can also deal with umlauten.

From Powershell 6 suffices UTF-8 without BOM…

An alternative to displaying powershell code correctly with umlauten would be PS hybrid batch:

demo.cmd

<# : Batch Abschnitt ,Batch sieht in dieser Zeile die Eingabe aus der Datei # an ein SprungLabel, Powershell sieht den begin eines Kommentars. 
start ""  powershell  "iex (gc '%~f0' -Encoding UTF8 -Raw | out-string)" 
exit /b
: Ende Batch und Powershellkommentar #>


#Ab hier  beliebiger  Powershellcode
Write-Host 'Test blüblkälöß'  -fo green
pause

…simply save UTF-8 encoded… also works under Powershell 2 to 5.1. Also has the advantage that you do not have to start with right click!

FigureEight
1 year ago

You can use the Replace() method:

$var = $var.Replace("ä", "ae").Replace("ö", "oe").Replace("ü", "ue").Replace("Ä", "Ae").Replace("Ö", "Oe").Replace("Ü", "Ue")

For $var, of course, you use your variable/string.

ohwehohach
1 year ago

Well, generally there is the “replace” method on strings. You can make a “ae” from a “ae”. Repeatedly applied for all relauds, you get your result.