Read utf-8 text file in vbscript

From the documentation:

The FSO can read only ASCII text files. You cannot use the FSO to read
Unicode files or to read binary file formats such as Microsoft Word or
Microsoft Excel.

Since you got weird characters, I guess that’s somewhat incorrect and the file was read in some 8-bit windows code page because if it really could read only ASCII, you would have seen ????

Anyway, if you can use ADO, you can do this:

Dim objStream, strData

Set objStream = CreateObject("ADODB.Stream")

objStream.CharSet = "utf-8"
objStream.Open
objStream.LoadFromFile("C:\Users\admin\Desktop\ArtistCG\folder.txt")

strData = objStream.ReadText()

objStream.Close
Set objStream = Nothing

Leave a Comment