Inververs Posted February 12, 2014 Share Posted February 12, 2014 How to read binary file and create array of bytes? Example: bytes string: 0xFD3EDFC4... Need this array: 0|0xFD 1|0x3E 2|0xDF 3|0xC4 ... ? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 12, 2014 Moderators Share Posted February 12, 2014 (edited) Have you looked in the help file at the binary functions, such as BinaryToString, StringToBinary, etc? Edited February 12, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Inververs Posted February 12, 2014 Author Share Posted February 12, 2014 Is there binaryToArray? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 12, 2014 Moderators Share Posted February 12, 2014 How about you crack the help file open and look "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Inververs Posted February 12, 2014 Author Share Posted February 12, 2014 (edited) No, there is no make of this, I looked course. There is only a function of conversion to a string, but I do not need a string, I need bytes. Edited February 12, 2014 by Inververs Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 12, 2014 Moderators Share Posted February 12, 2014 So, you can't convert to a string and then do a StringSplit? "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Inververs Posted February 12, 2014 Author Share Posted February 12, 2014 JLogan3o13, I understand your approach. Thank you. But the theme is: how to get an array of bytes, rather than how to use certain functions binarytostring Link to comment Share on other sites More sharing options...
jchd Posted February 12, 2014 Share Posted February 12, 2014 Want do you want/need to perform exactly? With an answer to this question it might be possible to guide you towards a simple and efficient solution ... or not. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Inververs Posted February 12, 2014 Author Share Posted February 12, 2014 (edited) I need For In iteration by byte in the binary data. In the loop to get the first byte, then the second, then the third, etc. Edited February 12, 2014 by Inververs Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 12, 2014 Moderators Share Posted February 12, 2014 I am sure someone will come along with a regex or something that works as well, but this works for me. #include <Array.au3> Local $aArray2[1] = [""] $sBinary = "0xFD3EDFC4" $aArray = StringSplit($sBinary, "") For $i = 3 To $aArray[0] Step 2 _ArrayAdd($aArray2, $aArray[1] & $aArray[2] & $aArray[$i] & $aArray[$i + 1]) Next _ArrayDelete($aArray2, 0) _ArrayDisplay($aArray2) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
bdr529 Posted February 17, 2014 Share Posted February 17, 2014 sorry for my bad english this can be an alternative using a function that can also be useful for other examples #Include <Array.au3> $sBinary = "0xFD3EDFC4" $count=2 $stringsplit_array=stringsplit_count($sBinary,$count) For $i = 1 To ubound($stringsplit_array)-1 $stringsplit_array[$i]=$stringsplit_array[0]&$stringsplit_array[$i] Next _ArrayDelete($stringsplit_array, 0) _ArrayDisplay($stringsplit_array) func stringsplit_count($string,$count) if $string="" Then return SetError(-1, 0, 0) else $stringlen=stringlen($string) $div=int($stringlen/$count) if $stringlen<>$count*$div then $div+=1 dim $stringsplit_array[$div] for $i=0 to $div-1 if $i=0 then $ii=1 Else $ii+=$count EndIf $stringsplit_array[$i]=stringmid($string,$ii,$count) Next SetError(1, 0, 0) return $stringsplit_array endif endfunc To community goes all my regards and thanks Link to comment Share on other sites More sharing options...
kylomas Posted February 17, 2014 Share Posted February 17, 2014 Inververs, Perhaps this... #Include <Array.au3> $sBinary = "0xFD3EDFC4" local $bArray = stringregexp($sBinary,'(?:0x)?(.{2})',3) _arraydisplay($bArray) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
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