Нашел в одном из скрипте функцию (не моя, но уже не вспомню где взял), может поможет:
| Код | Enum CHARSET CS_DOS = 866 CS_Windows = 1251 CS_ISO = 28595 CS_KOI8R = 20866 CS_UTF7 = 65000 CS_UTF8 = 65001 End Enum
Declare Function MultiByteToWideChar Lib "kernel32" _ (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 Declare Function WideCharToMultiByte Lib "kernel32" _ (ByVal CodePage As Long, _ ByVal dwFlags As Long, _ ByVal lpWideCharStr As String, _ ByVal cchWideChar As Long, _ ByVal lpMultiByteStr As String, _ ByVal cchMultiByte As Long, ByVal _ lpDefaultChar As String, _ ByVal lpUsedDefaultChar As Long) _ As Long
Function ConvertCharset(ByVal strString As String, ByVal FromCharset As CHARSET, ByVal ToCharset As CHARSET) As String Dim lngLength As Long Dim strWideChar As String Dim strReturn As String Dim lngReturnLength As Long Dim dwFlags As Long If FromCharset = CS_UTF7 Or FromCharset = CS_UTF8 Then dwFlags = 0 Else dwFlags = MB_PRECOMPOSED End If lngLength = Len(strString) strWideChar = String$(lngLength * 2, Chr$(0)) strReturn = String$(lngLength * 2, Chr$(0)) lngReturnLength = MultiByteToWideChar(FromCharset, dwFlags, strString, lngLength, strWideChar, lngLength) WideCharToMultiByte ToCharset, 0, strWideChar, lngReturnLength, strReturn, lngLength * 2, ByVal 0, 0 ConvertCharset = Left$(strReturn, lngReturnLength) End Function
|
|