Occasional Issue reading bytes of data

I have an issue where sometimes (20 times in 17,000 files) when I am
reading data from a file I don’t get the value I expect.

I am opening a file, reading the first 10 bytes and unpacking them as
Z3CCCCCCC. The issue appears that if one of the C values is 0x1A it is
read & unpacked as nil rather than 26.

Found my problem, I needed to open the file in binary mode (“rb” - kinda
fitting) for the bytes to be read in correctly.

Why is it that Windows has a binary file mode? What is the effect of
using the “b” flag on *nix platforms? is it simply ignored?

Rob

“Robert McGovern” tarasis@btopenworld.com wrote in message

Why is it that Windows has a binary file mode? What is the effect of
using the “b” flag on *nix platforms?

On Windows, the “text” mode automatically replaces every “\n” with two
chars: “\r\n” (ascii 10 and 13) and interprets ^Z (ascii 26) as the end of
the file. With “binary” mode there is no such conversion or interpretation.

This distinction is not seen on *nix and hence the two modes are equivalent
(AFAIK).

is it simply ignored?

I guess ! But I could be wrong …

– shanko