[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: enhance fh:read?
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Fri, 17 Jan 2003 12:24:31 +0100
Markus Huber wrote:
>
> Is it possible to enhance fh:read() in Lua-Code itself?
>
> Now I use this:
>
> Word= string.byte(Filehandle:read(1))*256
> +string.byte(Filehandle:read(1))
>
> But I would prefer this way:
>
> Word=Filehandle:read('w')
>
> (Please no discussion about Word 16 or 32 bit ;-)
I guess that that would be unportable.
On a big endian architecture, or reading from a file
that is big-endian, I think you'll have to
say
Word= string.byte(Filehandle:read(1))
+string.byte(Filehandle:read(1))*256
Lua uses only ANSI C, so it cannot know anything about
endianness.
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be