ZedBrannigan
ZedBrannigan

Reputation: 611

I just can't seem to get my german umlauts right with Powershell V2

Hello there and thanks in advance for your help.

I have a script which transforms my output into a desired format. I load the file with

$PreSystem = [IO.File]::ReadAllText("C:\Users\Soc.20150119.txt")

I process it and do this:

 # Write to file
  $output | Out-File -Filepath C:\Users\Soc.20150119_output.txt -append

Now each time, the Umlauts ä, ö, ü, ß are displayed as question marks in my output.

I tried

-encoding ASCII
-encoding unicode

and so on. But the problem persists. Can someone help me out, I'm starting to pull my hair :) Thank you so much!

BR, Tobi

Upvotes: 2

Views: 7014

Answers (1)

Micky Balladelli
Micky Balladelli

Reputation: 9991

If you want to continue using ReadAllText, you can specify the encoding like this:

[IO.File]::ReadAllText("C:\Users\Soc.20150119.txt", [System.Text.Encoding]::Unicode)

You can also test with [System.Text.Encoding]::UTF8, which I believe should work too.

Upvotes: 2

Related Questions