Import Text Files with Garbage Characters

I had a case in which we use VB.NET to import a text file and it didn't work properly. My code at first was:

Dim someString As String = Encoding.ASCII.GetString(someByteArray)

After researching for a while, I found out that the text file is encoded using UTF-8. Thus, switching it to the following code make it work properly:

Dim someString As String = Encoding.UTF8.GetString(someByteArray)

Encoding matters!

Comments

Popular posts from this blog

AWS EC2 Can't Reach EC2 Metadata Service After Subnet Change

A2 Hosting with .NET Core 2.1

Xcode CodeSign Incorrectly States Password is Incorrect