Berger Posted October 28, 2006 Posted October 28, 2006 Hi, I am using the RUN command to with the standard_i/o_flag - $STDOUT_CHILD to run xcopy. the output is going into file text. The problem is that the run command does not support unicode, and hebrew letters are comming as unknown signs. Any ideas hoe to get correct output? Thanks.
Fossil Rock Posted October 29, 2006 Posted October 29, 2006 Can you be a little more descriptive of what you are trying to accomplish, maybe a code sample. If you're trying to do what I think you're trying to do, I may have something that will help you. Agreement is not necessary - thinking for one's self is!
sulfurious Posted October 30, 2006 Posted October 30, 2006 I think what you need to do is change your active code page. the command chcp [nnn] will change it. Change this before you run the dos commands. Change it back afterwards. I do not know what the active code page # is for your language, but there are plenty of references online. However, you may still have problems. I am unsure that xcopy even supports 16bit encoding. So, if the characters you seek are 16bit, you will not get display correctly because a lot of dos is only 8bit encoding, likely resulting in ? marks in the unknown character positions. If your characters are in the ASCII realm, the active code page should do it. Sul.
Berger Posted November 2, 2006 Author Posted November 2, 2006 I think what you need to do is change your active code page. the command chcp [nnn] will change it. Change this before you run the dos commands. Change it back afterwards. I do not know what the active code page # is for your language, but there are plenty of references online. However, you may still have problems. I am unsure that xcopy even supports 16bit encoding. So, if the characters you seek are 16bit, you will not get display correctly because a lot of dos is only 8bit encoding, likely resulting in ? marks in the unknown character positions. If your characters are in the ASCII realm, the active code page should do it. Sul. Ok, I cna now be more specific. When the cmd program run, the output is going into text file. The content of the text file includes the unicode caracters correctly, includes the hebrew ones. Now, I am using the command _FileReadToArray("MyTextFile.txt",$as_Body) to put the text file data into array and then send it via email. The _FileReadToArray("MyMirror.txt",$as_Body) command change the hebrew unicode caracters into garbage bad caracters inside the array. Any ides how to use the _FileReadToArray command correctly? Thank, Berger.
Fossil Rock Posted November 2, 2006 Posted November 2, 2006 (edited) Can you post the Hebrew file for an experiment ? EDIT: AutoIT does not support Unicode, so that may be your problem, but there still may be a workaround. Edited November 2, 2006 by Fossil Rock Agreement is not necessary - thinking for one's self is!
amel27 Posted December 9, 2006 Posted December 9, 2006 Any ides how to use the _FileReadToArray command correctly?It is my edition of _File*Array commands for UNICODE files... May be read mode not set correctly... but simple Read-mode work correctly in my tests, while RAW-mode skip some file open errors (if file not exist) expandcollapse popupFunc _FileReadUnicodeToArray ($sFilePath, ByRef $aArray) Local $hFile = FileOpen ($sFilePath, 0) If $hFile = -1 Then SetError (1) Return 0 EndIf Local $uData = FileRead ($hFile, FileGetSize($sFilePath)) $aArray = StringSplit (StringStripCR (_WCStrToString ($uData)), @LF) FileClose ($hFile) Return 1 EndFunc Func _FileWriteUnicodeFromArray ($sFilePath, ByRef $a_Array, $i_Base = 0, $i_UBound = 0) Local $hFile If Not IsArray ($a_Array) Then SetError (2) Return 0 EndIf Local $last = UBound($a_Array) - 1 If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0 $hFile = FileOpen ($sFilePath, 2) If $hFile = -1 Then SetError (1) Return 0 EndIf FileWrite ($hFile, _StringToWCStr ($a_Array [$i_Base], 1)) For $x = $i_Base + 1 To $i_UBound $a_Array [$x] = @CRLF & $a_Array [$x] FileWrite ($hFile, _StringToWCStr ($a_Array [$x])) Next FileClose($hFile) Return 1 EndFunc Func _StringToWCStr (ByRef $sString, $mark = 0) Local $sizeIn = StringLen ($sString), $sizeOut= BitShift ($sizeIn, -1) Local $bufOut, $ptrOut, $wordOut If $sizeIn =0 Then If $mark Then Return Chr(0xFF) & Chr(0xFE) Return '' EndIf If $mark Then $bufOut = DllStructCreate ("byte[" & $sizeOut +2 & "]") DllStructSetData ($bufOut, 1, Chr(0xFF) & Chr(0xFE)) $ptrOut = DllStructGetPtr ($bufOut) $ptrOut +=2 Else $bufOut = DllStructCreate ("byte[" & $sizeOut & "]") $ptrOut = DllStructGetPtr ($bufOut) EndIf Local $ret = DllCall ("Kernel32.dll", "int", "MultiByteToWideChar", _ "int", 0, _ "int", 0, _ "str", $sString, _ "int", $sizeIn, _ "ptr", $ptrOut, _ "int", $sizeOut ) If $ret [0] Then Return DllStructGetData ($bufOut, 1) Else $ret = DllCall ("Kernel32.dll", "int", "GetLastError") SetError ($ret [0]) EndIf EndFunc Func _WCStrToString (ByRef $wcString) Local $sizeIn= StringLen ($wcString), $sizeOut = BitShift ($sizeIn, 1) If $sizeIn =0 Then Return '' Local $bufOut= DllStructCreate ("char[" & $sizeOut & "]") Local $bufIn = DllStructCreate ("byte[" & $sizeIn & "]") Local $ptrIn = DllStructGetPtr ($bufIn) DllStructSetData ($bufIn, 1, $wcString) If DllStructGetData ($bufIn, 1, 1) =-1 AND DllStructGetData ($bufIn, 1, 2) =-2 Then $ptrIn +=2 $sizeOut -=1 EndIf Local $ret = DllCall ("Kernel32.dll", "int", "WideCharToMultiByte", _ "int", 0, _ "int", 0, _ "ptr", $ptrIn, _ "int", $sizeOut, _ "ptr", DllStructGetPtr ($bufOut), _ "int", $sizeOut, _ "int", 0, _ "int", 0 ) If $ret [0] Then Return DllStructGetData ($bufOut, 1) Else $ret = DllCall ("Kernel32.dll", "int", "GetLastError") SetError ($ret [0]) EndIf EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now