RawRead()

Share your ideas as to how the documentation can be improved.
iseahound
Posts: 1447
Joined: 13 Aug 2016, 21:04
Contact:

RawRead()

27 Feb 2024, 19:15

Please add a note that if a UTF-8 BOM file is encountered, the file pointer is set to 3. Therefore calls to RawRead() will read 3 less bytes.

The user should add

Code: Select all

f.pos := 0
before calls to rawread or they may get errors.

This may be a bug.
User avatar
Ragnar
Posts: 614
Joined: 30 Sep 2013, 15:25

Re: RawRead()

07 Mar 2024, 05:19

There is already a note on the FileOpen page:
When a file containing a UTF-8 or UTF-16 byte order mark (BOM) is opened with read access, the BOM is excluded from the output by positioning the file pointer after it. Therefore, File.Pos may report 3 or 2 immediately after opening the file.
iseahound
Posts: 1447
Joined: 13 Aug 2016, 21:04
Contact:

Re: RawRead()

01 Apr 2024, 18:09

It should be added to RawRead however, as one would expect "raw" to mean unmodified.
RussF
Posts: 1269
Joined: 05 Aug 2021, 06:36

Re: RawRead()

02 Apr 2024, 06:36

I would have to agree with @iseahound here. Perhaps a warning that you must first check the fileobj.pos property and reset it to 0 if you want to be sure you are getting the first two bytes.

In fact, I would also argue that the FileOpen object should have an additional flag that opens a file in raw mode, initially forcing the file pointer to 0 rather than (maybe) 2 (or maybe not). While AHK may not be the best choice for processing binary data, there may be a circumstance where you need to as part of a larger application.

Russ

Return to “Suggestions on Documentation Improvements”

Who is online

Users browsing this forum: No registered users and 73 guests