[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Difference between a+b and bit32.band(a+b)
- From: HyperHacker <hyperhacker@...>
- Date: Fri, 9 Sep 2011 21:32:31 -0600
On Fri, Sep 9, 2011 at 18:41, Ross Berteig <Ross@cheshireeng.com> wrote:
> At 05:33 PM 9/9/2011, Petite Abeille wrote:
>>> Looks like io.lines can't read binary files. :(
>>As mentioned, try the "*L" option.
>
> And don't forget to open the file in binary mode as well,
> regardless of the Lua version. It won't matter on Linux, but on
> Windows, the default text mode will turn all CRLF pairs into a
> single newline character, which will also disturb a checksum.
>
> http://www.lua.org/work/doc/manual.html#pdf-io.open
>
> Note that if you used io.input() to open the file (which you
> probably did since you are using io.lines() rather than
> file:lines() in your code fragment) you don't get the chance to
> set the file to binary mode.
>
>
> Ross Berteig Ross@CheshireEng.com
> Cheshire Engineering Corp. http://www.CheshireEng.com/
>
>
>
Using io.lines() to iterate binary files is also a bad idea simply for
the possibility that you encounter an extremely long "line". For
example dealing with uncompressed graphics, or large ROM images padded
to the next power-of-two size, it's not unlikely you could encounter a
run of a megabyte or more without any line break character in it.
--
Sent from my toaster.
- References:
- Difference between a+b and bit32.band(a+b), waspoza
- Re: Difference between a+b and bit32.band(a+b), Duncan Cross
- Re: Difference between a+b and bit32.band(a+b), Luiz Henrique de Figueiredo
- Re: Difference between a+b and bit32.band(a+b), waspoza
- Re: Difference between a+b and bit32.band(a+b), Lee Hickey
- Re: Difference between a+b and bit32.band(a+b), waspoza
- Re: Difference between a+b and bit32.band(a+b), Duncan Cross
- Re: Difference between a+b and bit32.band(a+b), waspoza
- Re: Difference between a+b and bit32.band(a+b), waspoza
- Re: Difference between a+b and bit32.band(a+b), Petite Abeille
- Re: Difference between a+b and bit32.band(a+b), Ross Berteig