Rozek Posted August 8, 2007 Share Posted August 8, 2007 Hello! I'm new to AutoIt and this forum, thus, please forgive me, should the following question look too much like that of a newbie... In my AutoIt script, I have to look for some text within otherwise binary content (to be more precise: a binary file somewhere contains an XML document which I'm going to extract). Loading the file into a binary is not a problem - but (since the file purposefully contains null bytes) searching for "<?xml" is one. I tried - to BinaryToString(...) the binary - this sometimes even lead to a crash(!) - to String(...) the binary - that gave me two characters per byte (measured with StringLen()) - to treat the binary as if it already were a string None of the approaches was successfull, I was never able to find my pattern (neither with StringInStr(...,"<?xml") nor with StringRegExp(..., "<[?]xml", 1)) How can I search within a binary, convert the binary into an (ASCII) string which "ignores" the null bytes or just convert the null bytes into something else (as they are not relevant) Thanks in advance for any help! Kind regards, Andreas Rozek Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 8, 2007 Moderators Share Posted August 8, 2007 I have no idea why BinaryToString would cause a crash... but did you open the file in Binary Mode first? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Rozek Posted August 8, 2007 Author Share Posted August 8, 2007 I used local $InStream = FileOpen(...,16) local $Content = FileRead($InStream) FileClose($InStream) local $hugo = BinaryToString($Content) (not mentioning any error handling etc.) Whether the script crashes or not depends on the actual file contents - some files let the script survive, others let it crash.. Kind regards, Andreas Rozek Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 9, 2007 Moderators Share Posted August 9, 2007 I used local $InStream = FileOpen(...,16) local $Content = FileRead($InStream) FileClose($InStream) local $hugo = BinaryToString($Content)(not mentioning any error handling etc.)Whether the script crashes or not depends on the actual file contents - some files let the script survive, others let it crash..Kind regards,Andreas RozekSo you don't really have a replication script to provide for us to help you? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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