Well, you've just read a file encoded in UTF-8. You need to use StrConv to convert it to UTF-16.
Since you're trying to get rid of StrConv, you could use MultiByteToWideChar. Here's a snippet (air code):
Code:Private Declare Function MultiByteToWideChar Lib "kernel32.dll" ( _ 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 Private Const CP_UTF8 As Long = 65001 Private Function ToUTF16(Data As String, Optional FromEncoding As Long = CP_UTF8) As String Dim lSize As Long lSize = MultiByteToWideChar(CP_UTF8, 0, StrPtr(Data), Len(Data), 0, 0) ToUTF16 = Space$(lSize) MultiByteToWideChar CP_UTF8, 0, StrPtr(Data), Len(Data), StrPtr(ToUTF16), lSize End Function 'And you'd call it like this after your ReadFile2 call: sText = ToUTF16(sText) 'and do something else with it




Reply With Quote
