Cgi.rb replacing "0x0a" symbols with "0x0d 0x0a"?

Hi!
I am new to ruby and lack of understanding
– Ruby 1.6.7 & Apache 2.0.40 on win2k –

When i trying to make simple file-uploader i have been confront with a problem

[test.html]

···
attach file: --------------

then [test.rb]

#!/ruby/bin/ruby
require ‘cgi’

someFile, = cgi[‘attach_file’]

data = someFile.read

newFile = File.new(CustomDir + newFilename + extension, “w”)
newFile.write(data)
newFile.close

Binary file successfully written to the destination but replaced
"0x0a" symbols with “0x0d 0x0a” (’\r’->’\r\n’)

Please, can anyone explain me - what’s wrong?

P.S. sorry for my bad english. not expirienced yet :wink:


Andrew “RayZ” V Rumm

Well, I know nothing on win32 but try with "wb"

newFile = File.new(CustomDir + newFilename + extension, "w")

   newFile = File.new(CustomDir + newFilename + extension, "wb")

do say that you want a binary file (without conversion)

Guy Decoux

RayZ wrote:

I am just guessing (I don’t use MSW), but you may try :

newFile = File.new(CustomDir + newFilename + extension, “wb”)

Note the “wb” open modifier (I would try “bw” also…)

Regards, Christian

Thanx, Guy
That’s it. It’s works fine with “wb”.

I am just guessing (I don’t use MSW), but you may try :
newFile = File.new(CustomDir + newFilename + extension, “wb”)
Note the “wb” open modifier (I would try “bw” also…)
Regards, Christian

oke, i am developing my web-server under Windows locally now, and in
future i am planning to use the same ruby sources under Linux

will that “wb” open modifier works with Linux ?

Andrew Rumm.

RayZ wrote:

oke, i am developing my web-server under Windows locally now, and in
future i am planning to use the same ruby sources under Linux

will that “wb” open modifier works with Linux ?

Andrew Rumm.

Yes.