[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: CR/LF in data read from a socket

Pit Capitain

1/25/2006 7:53:00 AM

mac schrieb:
> outputFile = File.new( "test_image"+ind.to_s,"w")
> outputFile.syswrite(pdu)
> ...
> When I load the output file in to a hex editor (Ultraedit) I see "0D" and
> "0A" chars (CR and LF) in the file, several of them where they should not
> be.

Hi Mac,

if you're on Windows you have to open the output file in binary mode:

outputFile = File.new( "test_image"+ind.to_s, "wb" )

Also look at the block form of File.open to automatically close the
output file.

Regards,
Pit


2 Answers

mac

1/26/2006 4:42:00 AM

0

Pit,
Thanks for the correction, that fixed it! Really appreciate it.
There is obiviously lack of dacumentation in Ruby world.


On 1/25/06, Pit Capitain <pit@capitain.de> wrote:
>
> mac schrieb:
> > outputFile = File.new( "test_image"+ind.to_s,"w")
> > outputFile.syswrite(pdu)
> > ...
> > When I load the output file in to a hex editor (Ultraedit) I see "0D"
> and
> > "0A" chars (CR and LF) in the file, several of them where they should
> not
> > be.
>
> Hi Mac,
>
> if you're on Windows you have to open the output file in binary mode:
>
> outputFile = File.new( "test_image"+ind.to_s, "wb" )
>
> Also look at the block form of File.open to automatically close the
> output file.
>
> Regards,
> Pit
>
>

Gene Tani

1/26/2006 5:38:00 AM

0


mac wrote:
> Pit,
> Thanks for the correction, that fixed it! Really appreciate it.
> There is obiviously lack of dacumentation in Ruby world.
>

I had to respond to this. I'm not sure if you're comparing to
java/.NET, or maybe perl/python or lisp/smalltalk/ML/some of those
kinds of environments. There actually is heaps of info on the net.
I've seen people produce lots of top-quality code in response to
queries on this mail list, really detailed analysis, etc. It's really
extraordinary, sometimesyou have to ask.