WideCharToMultiByte 64 |
Private Declare PtrSafe Function WideCharToMultiByte Lib "kernel32" ( _ ByVal CodePage As Long, _ ByVal dwFlags As Long, _ ByVal lpWideCharStr As LongPtr, _ ByVal cchWideChar As Long, _ ByVal lpMultiByteStr As LongPtr, _ ByVal cbMultiByte As Long, _ ByVal lpDefaultChar As LongPtr, _ ByVal lpUsedDefaultChar As LongPtr) As LongPtr Private Const CP_UTF8 = 65001 Public Function StringtoUTF8(ByVal Src As String) As String Dim SrcLng As Long Dim DstLng As Long Dim Dst() As Byte Dim I As Long SrcLng = Len(Src) If SrcLng <> 0 Then DstLng = WideCharToMultiByte(CP_UTF8, 0, StrPtr(Src), SrcLng, 0, 0, 0, 0) If DstLng > 0 Then ReDim Dst(DstLng - 1) DstLng = WideCharToMultiByte(CP_UTF8, 0, StrPtr(Src), SrcLng, VarPtr(Dst(0)), DstLng, 0, 0) StringtoUTF8 = String(DstLng, " ") For I = 0 To UBound(Dst) Mid(StringtoUTF8, I + 1, 1) = Chr(Dst(I)) Next End If End If End Function
http://www.sql.ru/forum/1271604/widechartomultibyte-dlya-64-bitnogo