Hi,
I tried to read a binary file with a char '0x1A' (EOF on window I guess). The method
File::each_byte stops at this char.
How can get it to read the whole file? Is there a binary mode for file operation?
Thanks
Hi,
I tried to read a binary file with a char '0x1A' (EOF on window I guess). The method
File::each_byte stops at this char.
How can get it to read the whole file? Is there a binary mode for file operation?
Thanks
File.open name, 'rb' do |fp|
# ...
end
PS: File::each_byte references a class method. You meant File#each_byte.
On 31 Aug 2005, at 21:24, hsun wrote:
Hi,
I tried to read a binary file with a char '0x1A' (EOF on window I guess). The method
File::each_byte stops at this char.
How can get it to read the whole file? Is there a binary mode for file operation?
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
hsun wrote:
Hi,
I tried to read a binary file with a char '0x1A' (EOF on window I guess).
The methodFile::each_byte stops at this char.
How can get it to read the whole file? Is there a binary mode for file operation?
Thanks
contents = open(filename, "rb") { |f| f.read }
open(path, 'rb') do |f|
...
end
hth.
-a
On Thu, 1 Sep 2005, hsun wrote:
Hi,
I tried to read a binary file with a char '0x1A' (EOF on window I guess). The method
File::each_byte stops at this char. How can get it to read the whole file? Is there a binary mode for file operation?
Thanks
email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
hello.
> File::each_byte stops at this char.
>
> How can get it to read the whole file? Is there a binary mode for file operation?contents = open(filename, "rb") { |f| f.read }
see also: IO.binmode
q2hdp://void/3d/universe/milky-way-galaxy/orion-arm/sol-solar-system/
3rd-planet/fareast/jp/tky/shigetomi.takuhiko.5618
That is one of the things that I did not understand for a long time,
because File#each_byte is valid ruby, a constant and a comment, and I
did not get that it is a way to say "the method of a file instance".
So I just wanted to pop in here and say:
File#each means each is a method of a File instance
maybe that helps someone with the same confusion I had
regards,
Brian
On 01/09/05, Eric Hodel <drbrain@segment7.net> wrote:
On 31 Aug 2005, at 21:24, hsun wrote:
> Hi,
>
> I tried to read a binary file with a char '0x1A' (EOF on window I
> guess). The method
>
> File::each_byte stops at this char.
> How can get it to read the whole file? Is there a binary mode for
> file operation?File.open name, 'rb' do |fp|
# ...
endPS: File::each_byte references a class method. You meant
File#each_byte.
--
http://ruby.brian-schroeder.de/
Stringed instrument chords: http://chordlist.brian-schroeder.de/