Code: Select all
Declare Function WideCharToMultiByte Lib "kernel32" Alias "WideCharToMultiByte" _
(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
Declare Function MultiByteToWideChar Lib "kernel32" Alias "MultiByteToWideChar" _
(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
Const MB_PRECOMPOSED = &H1
Const WIN = 1251
Const KOI = 20866
Const DOS = 866
Const Iso = 28595
Const UTF8=65001
'*****************************************
Function Convert( strSrc As String, nFromCP As Long, nToCP As Long) As String
print"strSrc=";strSrc
Dim nLen As Long
Dim strDst As String
Dim strRet As String
Dim nRet As Long
nLen = Len(strSrc)
print"nLen=";nLen
strDst = String$(nLen * 2, Chr(44))
strRet = String$(nLen * 2, Chr(45))
nRet = MultiByteToWideChar(nFromCP, MB_PRECOMPOSED, strSrc, nLen, strDst, nLen)
nRet = WideCharToMultiByte(nToCP, 0, strDst, nRet, strRet, nLen * 2, 0, 0)
Convert = Left$(strRet, nRet)
End Function
dosStr$="qwerty"
winStr$= Convert(dosStr$, dos, WIN)
print "winStr$="; winStr$;"<<<"
UTF8Str$=Convert(winStr$, WIN, UTF8)
print "UTF8Str$="; UTF8Str$;"<<<"
dosStr$=Convert(UTF8Str$, UTF8, dos)
print "dosStr$="; dosStr$;"<<<"
Code: Select all
dosStr$=Convert(UTF8Str$, UTF8, dos)
print "dosStr$="; dosStr$;"<<<"
How can I correct this?
With best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/ - Rapid-Q Basic documentation Project
RQ Search and Replace - http://mira.home.line1.ru/rqsr.html