lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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 

Word= string.byte(Filehandle:read(1))

Lua uses only ANSI C, so it cannot know anything about 

"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer