Declare Function BiDiConvertAnsiToOem Lib "BIDI32.DLL" Alias "#3" _
(lpConvertInfo As CONVERTINFO, ByRef lpStrInfo As STRINFO) As Long
Declare Function BiDiConvertOemToAnsi Lib "BIDI32.DLL" Alias "#2" _
(lpConvertInfo As CONVERTINFO, ByRef lpStrInfo As STRINFO) As Long
Private Type CONVERTINFO
hWndOwner As Long
nOemCP As Long
fOemLayout As Long
nWindowsCP As Long
fControlChars As Long
fShowLayout As Long
nUILang As Long
End Type
Type STRINFO
lpStrIn As String
cchIn As Long
lpStrOut As String
cchOut As Long
End Type
Public Function LogicalToVisual(LogicalStr As String) As String
Dim ConvInfo As CONVERTINFO
Dim StrInfo1 As STRINFO
Dim Buf As String * 2000
ConvInfo.nOemCP = 1
ConvInfo.fOemLayout = 2
ConvInfo.nWindowsCP = 1255
ConvInfo.fControlChars = 1
ConvInfo.nUILang = &H409
ConvInfo.fShowLayout = 1
StrInfo1.lpStrIn = LogicalStr
StrInfo1.cchIn = Len(LogicalStr)
StrInfo1.lpStrOut = Buf
StrInfo1.cchOut = Len(Buf)
BiDiConvertAnsiToOem ConvInfo, StrInfo1
LogicalToVisual = Trim(ZeroTrim(StrInfo1.lpStrOut))
End Function
Public Function VisualToLogical(LogicalStr As String) As String
Dim ConvInfo As CONVERTINFO
Dim StrInfo1 As STRINFO
Dim Buf As String * 2000
ConvInfo.nOemCP = 1
ConvInfo.fOemLayout = 2
ConvInfo.nWindowsCP = 1255
ConvInfo.fControlChars = 0
ConvInfo.nUILang = &H409
ConvInfo.fShowLayout = 1
StrInfo1.lpStrIn = LogicalStr
StrInfo1.cchIn = Len(LogicalStr)
StrInfo1.lpStrOut = Buf
StrInfo1.cchOut = Len(Buf)
BiDiConvertOemToAnsi ConvInfo, StrInfo1
VisualToLogical = ZeroTrim(StrInfo1.lpStrOut)
End Function
Private Function ZeroTrim(Str1 As String) As String
Dim Pos As Long
Pos = InStr(Str1, Chr(0))
If Pos > 0 Then
ZeroTrim = Mid(Str1, 1, Pos - 1)
Else
ZeroTrim = Str1
End If
End Function
|