: 1 |
|
: ISO to ANSI
|
: 04.10.05 15:51
|
|
: Ejara | ICQ: 151006307
|
ISO ANSI
.
|
: 3 : AndreyMp
ICQ: 237822510
: 28 : 1182
|
| | #3
|
: 04.10.05 17:26
|
Option Explicit
Enum Code
Win = 1
  os = 2
Koi = 3
Iso = 5
End Enum
Function Recode(Char As String, Src As Code, Dest As Code) As String
Const wDos As String = ""
Const wIso As String = "ע"
Const wKoi As String = ""
Const wWin As String = ""
Const NotRecodedChar As String = "?"
If Src = Dest Then
Recode = Char
Exit Function
End If
Dim t As String, i As Long, tt As String, a As Long, ss As String, ch As String
If Src = Win Then
t = Char
Else
Select Case Src
Case Koi: ss = wKoi
Case Dos: ss = wDos
Case Iso: ss = wIso
End Select
For i = 1 To Len(Char)
ch = Mid(Char, i, 1)
If Asc(ch) < 128 Then
t = t & ch
Else
a = InStr(1, ss, ch, vbBinaryCompare)
If a = 0 Then
t = t & NotRecodedChar
Else
t = t & Mid$(wWin, a, 1)
End If
End If
Next i
End If
If Dest = Win Then
Recode = t
Else
Select Case Dest
Case Koi: ss = wKoi
Case Dos: ss = wDos
Case Iso: ss = wIso
End Select
For i = 1 To Len(Char)
ch = Mid(t, i, 1)
If Asc(ch) < 128 Then
tt = tt & ch
Else
a = InStr(1, wWin, ch, vbBinaryCompare)
If a = 0 Then
tt = tt & NotRecodedChar
Else
tt = tt & Mid$(ss, a, 1)
End If
End If
Next i
Recode = tt
End If
End Function
|
: 4 : AndreyMp
ICQ: 237822510
: 28 : 1182
|
| | #4
|
: 04.10.05 17:27
|
.
Option Explicit
Enum idCodePage
Win = 1251
  os = 866
Koi = 20866
Iso = 28595
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 Long, _
ByVal cchWideChar As Long) As Long
Declare Function WideCharToMultiByte Lib "kernel32" ( ByVal CodePage As Long, ByVal dwFlags As Long, _
ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As String, _
ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
Public Function ConvertCodePage(SourseString As String, inPage As idCodePage, outPage As idCodePage) As String
Dim LenSourseString As Long
Dim strFirst As String
Dim strSecond As String
Dim RetStrLong As Long
LenSourseString = Len(SourseString)
strFirst = String(LenSourseString * 2, Chr(0))
strSecond = String(LenSourseString * 2, Chr(0))
RetStrLong = MultiByteToWideChar(inPage, &H1, SourseString, LenSourseString, StrPtr(strFirst), LenSourseString)
RetStrLong = WideCharToMultiByte(outPage, 0, StrPtr(strFirst), RetStrLong, strSecond, LenSourseString * 2, ByVal 0, 0)
ConvertCodePage = Left(strSecond, RetStrLong)
End Function
|
: 1 |