EddieBoy Posted June 15, 2013 Share Posted June 15, 2013 (edited) I found that using Binary(FileRead($x)) with FileOpen($x) can cause failed reads (blank) on systems that use 2byte per letter text encoding. It's not clearly stated in the help file that the default mode for FileOpen() is text and should not be used to read binary data. Or, this may be a bug in Autoit. I in this example, $data should return "FF000000" through "C00000", but as you can see from my screen shot, it returns empty reads between FD and DF. This seems to happen on computers set to 2byte per letter text encodings. Local $data For $i = 1 to 0xff $data= Binary($i) & Binary($data) Next $file = FileOpen(@WorkingDir & "\.example_DELETE.txt",2) FileWrite($file, $data) FileSetPos($file,0,0) $data = "" For $i = 1 To 0xff $data = Binary($data) & Binary(FileRead($file,1)) Next MsgBox(0,"",$data) FileClose($file) Edited June 16, 2013 by EddieBoy Link to comment Share on other sites More sharing options...
EddieBoy Posted June 16, 2013 Author Share Posted June 16, 2013 I'll just add, if you live in the US and have had programs fail when sent overseas to unicode etc users, this issue may be the culprit. When I changed my code to use "forced binary" FileOpen($x,16), the problem went away. Link to comment Share on other sites More sharing options...
trancexx Posted June 16, 2013 Share Posted June 16, 2013 Unicode is alqaeda etc. Mat, jchd, DW1 and 1 other 4 ♡♡♡ . eMyvnE 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