Hi to all,
I found a solution to the Unicode problem in this site
http://groups.google.ie/group/microsoft.public.vb.general.discussion/msg/f3c3fd8182563e?hl=en
I add the code and do some modification to the WID Scanner and it work fine now with the Arabic character
this is the codes:
Private Const CP_UTF8 = 65001
Private Declare Function MultiByteToWideChar Lib "kernel32" ( _
ByVal CodePage As Long, ByVal dwFlags As Long, _
ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, _
ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long
Public Function sUTF8ToUni(bySrc() As Byte) As String
' Converts a UTF-8 byte array to a Unicode string
Dim lBytes As Long, lNC As Long, lRet As Long
lBytes = UBound(bySrc) - LBound(bySrc) + 1
lNC = lBytes
sUTF8ToUni = String$(lNC, Chr(0))
lRet = MultiByteToWideChar(CP_UTF8, 0, VarPtr(bySrc(LBound(bySrc))),
lBytes, StrPtr(sUTF8ToUni), lNC)
sUTF8ToUni = Left$(sUTF8ToUni, lRet)
End Function
Public Sub ConvertUTF8File(sUTF8File As String, sANSIFile As String)
Dim iFile As Integer, bData() As Byte, sData As String, lSize As Long
' Get the incoming data size
lSize = FileLen(sUTF8File)
If lSize > 0 Then
ReDim bData(0 To lSize - 1)
' Read the existing UTF-8 file
iFile = FreeFile()
Open sUTF8File For Binary As #iFile
Get #iFile, , bData
Close #iFile
' Convert all the data to Unicode (all VB Strings are Unicode)
sData = sUTF8ToUni(bData)
Else
sData = ""
End If
' Now write it all out to the ANSI file
iFile = FreeFile()
Open sANSIFile For Output As #iFile
Print #iFile, sData
Close iFile
End Sub
thanks to the writer Tony Proctor
and I do this modification to the WID Scanner:
'1.1 added hyphen to output-path
sDBCS = "%comspec% /c " + "grep -a " + Chr(34) + "<Name>" + Chr(34) + Space(1) + Chr(34) + cFileStorePath + sFilePath + sFileName + Chr(34) + " > " + Chr(34) + cFL_Path + cTempObjects + Chr(34)
'Debug.Print sDBCS
'Debug.Print cFileStorePath + sFilePath
oShell.Run sDBCS, 7, True
Call ConvertUTF8File(cFL_Path + cTempObjects, cFL_Path + "TEMP.txt")
Set oFile2 = oFso.OpenTextFile(cFL_Path + "TEMP.txt", 1)
just create a temp.txt and call the function
DataAdmin (BOB member since 2006-08-23)