Public Declare Function MultiByteToWideChar Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long Public Const CP_UTF8 = 65001Public Function UTF8_Decode(bUTF8() As Byte) As String Dim lRet As Long Dim lLen As Long Dim lBufferSize As Long Dim sBuffer As String Dim bBuffer() As Byte
Public Const CP_UTF8 = 65001Public Function UTF8_Decode(bUTF8() As Byte) As String
Dim lRet As Long
Dim lLen As Long
Dim lBufferSize As Long
Dim sBuffer As String
Dim bBuffer() As Byte
lLen = UBound(bUTF8) + 1
If lLen = 0 Then Exit Function
lBufferSize = lLen * 2
sBuffer = String$(lBufferSize, Chr(0))
lRet = MultiByteToWideChar(CP_UTF8, 0, VarPtr(bUTF8(0)), lLen, StrPtr(sBuffer), lBufferSize)
If lRet <> 0 Then
sBuffer = Left(sBuffer, lRet)
End If
UTF8_Decode = sBuffer
End Functiondim b() as byte
open "xxx" for binary as #1
redim b(lof(1)-1)
get #1,,b
close #1
debug.print UTF8_Decode(b())