Isaac
Isaac

Reputation: 170

How to read text file in UTF8 format using IO?

How to read text files using some encoding in powershell?

I am doing the following:

$text = [System.IO.File]::ReadAllLines("path.txt")
$text

But I needed to put the UTF8 encode, how can I do that?

Upvotes: 0

Views: 575

Answers (1)

Alex Korobchevsky
Alex Korobchevsky

Reputation: 165

This should do it:

[System.IO.File]::ReadAllLines("path.txt", [System.Text.Encoding]::UTF8)

Upvotes: 1

Related Questions