Topic: WideCharToMultiByte for 64 bit

Good afternoon
Used earlier in 32 bit Accsess function WideCharToMultiByte for transfer of lines in utf8

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))
End If
End If
End Function

But in 64 bit it does not work, and suddenly it was required.
Somebody works with 64 bit? Prompt, what it is necessary to change?


Re: WideCharToMultiByte for 64 bit

In the evening I can look;
Now I see that WideCharToMultiByte at you returns LongPtr, and then you appropriate this value of a variable with type Long.
Check up, business can in it.


Re: WideCharToMultiByte for 64 bit

Except usage  functions are also other variant (here at a forum already somehow gave the reference), look, can and it is useful


Re: WideCharToMultiByte for 64 bit

Vakshul Sergey;
Thanks, the kind person! Earned!
I already broke a head trying to understand in what pointers was tangled, and about result of function forgot... sad