From: Xavier Noria Date: 2009-08-19T05:39:12+09:00 Subject: Re: fromdos dos2unix in ruby On Tue, Aug 18, 2009 at 10:15 PM, Robert Klemme wrote: > WIN_LE = "\r\n".freeze > > File.open ARGV[0] do |in| >  File.open ARGV[1], "wb" do |out| >    in.each do |line| >      line.chomp! >      out.print line, WIN_LE Hey but this is dos2unix :-). You can't read in text-mode just like that in a portable way, because chomp! only chomps "\n". If you can assume the program is gonna run only on Windows then the solution is trivial: read in text-mode, and write in binary mode. No chomping or gsubs needed, just read and write. If the program has to be portable then you need to deal with the spurious \015 that may come up.