Public Declare Function WideCharToMultiByte
Lib "coredll.dll" _
(ByVal CodePage As Long, _
ByVal Flags As Long, _
ByVal MultiByteStr As String, _
ByVal MultiByteStrSize As Long, _
ByVal WideCharStr As String, _
ByVal WideCharStrSize As Long, _
ByVal lpDefaultChar As String, _
ByVal lpUsedDefaultChar As Boolean) As Long
Public Declare Function MultiByteToWideChar
Lib "Coredll" _
(ByVal CodePage As Long, _
ByVal dwFlags As Long, _
ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As String, _
ByVal cchWideChar As Long) As Long
Function Format_to_ANSI(wide_string
As String) As String
'WideCharToMultiByte
Dim strAnsi
Dim strAnsiLen As Long
strAnsiLen = WideCharToMultiByte(0, 0, wide_string,
Len(wide_string), strAnsi, 0, 0, 0)
strAnsi = Space(strAnsiLen) 'allocate a string for ansi
string.
strAnsiLen = WideCharToMultiByte(0, 0, wide_string,
Len(wide_string), strAnsi, strAnsiLen, 0, 0)
Format_to_ANSI = strAnsi
End Function
Function Format_to_UNICODE(multiByteData
As String) As String
'MultiByteToWideChar
'1) code Page used for conversion CP_ACP = 0
'2) Flag Contants
'3) Data To be Converted
'4) -1 The Data To be Converted is to be null terminated and returns Length
'5) To be Translated String
'6) The length of the receiving buffer ..if 0 returns the size of 5
Dim wideCharData
As String
Dim wideCharDataLen
As Long
Dim rc As
Long
wideCharData = ""
wideCharDataLen = MultiByteToWideChar(0, 0, multiByteData,
-1, vbNullString, 0)
wideCharData = String(wideCharDataLen, " ")
rc = MultiByteToWideChar(0, 0, multiByteData, -1,
wideCharData, wideCharDataLen)
Format_to_UNICODE = wideCharData
End Function