Home > Software engineering >  How to read text file in UTF8 format using IO?
How to read text file in UTF8 format using IO?

Time:06-11

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?

CodePudding user response:

This should do it:

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