hCORe писал(а):Для Char<->KOI8 сойдет и WideCharToMultiByte/MultiByteToWideChar
tyomitch писал(а):Не верю. Покажи пример.
Option Explicit
Private 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
Private 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
Private Const MB_PRECOMPOSED = &H1
Private Sub Form_Load()
Const WIN = 1251
Const KOI = 20866
Const DOS = 866
MsgBox Convert(Convert(Convert("Ну ты, Тёмыч, дал!", WIN, DOS), DOS, KOI), KOI, WIN)
End Sub
Private Function Convert(ByVal strSrc As String, ByVal nFromCP As Long, ByVal nToCP As Long) As String
On Error Resume Next
Dim nLen As Long
Dim strDst As String
Dim strRet As String
Dim nRet As Long
nLen = Len(strSrc)
strDst = String(nLen * 2, Chr(0))
strRet = String(nLen * 2, Chr(0))
nRet = MultiByteToWideChar(nFromCP, MB_PRECOMPOSED, strSrc, nLen, strDst, nLen)
nRet = WideCharToMultiByte(nToCP, 0, strDst, nRet, strRet, nLen * 2, ByVal 0, 0)
Convert = Left$(strRet, nRet)
End Function
Сейчас этот форум просматривают: AhrefsBot, SemrushBot и гости: 114