Forum: Ruby on Rails Rails cross platform problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7fbd0e99b27064b14793f028022974e5?d=identicon&s=25 Zhao Yi (youhaodeyi)
on 2009-03-10 01:43
My Rails working on a Linux system and a client access this server from
Windows. The client inputs something in a text area and click submit, in
the server side, it put the input into a file. The problem is that at
the end of each line in the file, there is a "^M". How can I avoid this?
I use File.puts method to write to the file.

53be54e5db4dc58e4980db5a8255621b?d=identicon&s=25 Harold (Guest)
on 2009-03-10 20:57
(Received via mailing list)
This is related to the fact that on *nix the default end of line
character is \n, and on windows, it's \r\n (note that this is not Ruby
specific, but platform specific - Ruby is just following along).

There's a utility on unixes called unix2dos which you can use to
substitute all \n characters to \r\n, or if you need to stay in Ruby-
land, use gsub with something like gsub!(/\n/,"\r\n").

Hope that helps,
This topic is locked and can not be replied to.