Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Binary( )conversion fail on file opened in 'text' mode

$
0
0

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)

 

examp_zps86f40c69.jpg


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>