This file is in UTF-8 string format. VB does not provide a mechanism to read this kind of text. You will have to use an API call to transform this to the standard UTF-16 VB String format.
Private Declare Function MultiByteToWideChar Lib "Kernel32.dll" ( _
ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByRef lpMultiByteStr As Byte, _
ByVal cbMultiByte As Long, _
ByVal lpWideCharStr As Long, _
ByVal cchWideChar As Long _
) As Long
' "Code Page" for UTF8.
Private Const CP_UTF8 As Long = 65001
Function ReadAllFromUtf8TextFile(ByRef the_sFileName As String) As String
Dim nFileNo As Long
Dim abytData() As Byte
Dim nDataLen As Long
Dim nStringLen As Long
' Get the next available file no.
nFileNo = FreeFile
' Open the file as binary data, resize a Byte array to fit, copy the file contents into the Byte array, and close the file.
Open the_sFileName For Binary As #nFileNo
nDataLen = LOF(nFileNo)
ReDim abytData(1 To nDataLen)
Get #nFileNo, , abytData()
Close #nFileNo
' Work out the size in characters that the data will be when converted.
nStringLen = MultiByteToWideChar(CP_UTF8, 0&, abytData(1), nDataLen, 0&, 0&)
' Allocate an output string buffer for this number of characters.
ReadAllFromUtf8TextFile = Space$(nStringLen)
' Actually do the conversion of the data in the Byte array to the output string buffer.
MultiByteToWideChar CP_UTF8, 0&, abytData(1), nDataLen, StrPtr(ReadAllFromUtf8TextFile), nStringLen
End Function
Private Sub Command_Click()
MsgBox ReadAllFromUtf8TextFile("C:\Document1.txt")
End Sub