Hello mate!
I've done this function some years ago, I don't know if it works... actually, I don't remember if it came to work.
I can't test it because in this PC I have only installed Ubuntu...
Option Explicit
'// kernel32.dll
Private Declare Function MultiByteToWideChar Lib "kernel32.dll" (ByVal CodePage As Long, ByVal dwFlags As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Private Declare Function WideCharToMultiByte Lib "kernel32.dll" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
'// Const
Private Const CP_UTF8 As Long = &HFDE9 '65001
'// Enum
Public Enum CONV_TYPE
Unicode = vbUnicode
UTF8 = vbFromUnicode
End Enum
'// Function
Public Function StrConversion(ByRef vEntry As Variant, eConv As CONV_TYPE) As Variant
Dim lRet As Long
Dim lLen As Long
Dim lBuffer As Long
Dim sBuffer As String
Dim bvOutput() As Byte
On Error GoTo Exit_
If eConv = Unicode Then
lLen = LenB(vEntry) \ 2
If lLen Then
lBuffer = lLen + lLen + lLen + 1
ReDim bvOutput(lBuffer - 1) As Byte
lRet = WideCharToMultiByte(CP_UTF8, 0, StrPtr(vEntry), lLen, bvOutput(0), lBuffer, vbNullString, 0)
If lRet Then
ReDim Preserve bvOutput(lRet - 1) As Byte
StrConversion = bvOutput
End If
End If
Else
lLen = UBound(vEntry) + 1
If lLen > 1 Then
lBuffer = lLen + lLen
sBuffer = Space$(lBuffer)
lRet = MultiByteToWideChar(CP_UTF8, 0, vEntry(0), lLen, StrPtr(sBuffer), lBuffer)
If lRet Then
StrConversion = Left$(sBuffer, lRet)
End If
End If
End If
Exit_:
End Function
I hope it works, or at least it helps you to make your own function.
Good luck!
DoEvents!