From: "Aaron D. Gifford" Date: 2010-06-05T10:45:28+09:00 Subject: Re: pack('m') and Windows files Emiliano wrote: >> The results are that I receive a mail that lacks of the 'end of lines', >> in which place there are little squares (one per each line, to be fair). >> Also, filetype is Unix (and not Dos/Windows). >> >> I tried previously to substitute \n with \r\n: >> content = File.read(filename).gsub(/\n/, '\r\n') To which I responded: > Make sure you're using double-quotes for "\r\n" and not single-quotes. I suppose I should have elaborated: irb(main):001:0> '\n' => "\\n" irb(main):002:0> "\n" => "\n" Notice how encapsulating the backslash within single quotes results in the string "\\n"? Backslashes inside single-quoted strings escape the backslash itself, and also single quotes, but not \r\n CR+LF escape sequences: irb(main):001:0> 'This is a backslash: \\' => "This is a backslash: \\" irb(main):002:0> "This is a backslash: \\" => "This is a backslash: \\" irb(main):003:0> 'This is a single-quote: \'' => "This is a single-quote: '" irb(main):004:0> 'But other escape sequences do not work: \r\n\t\b' => "But other escape sequences do not work: \\r\\n\\t\\b" irb(main):005:0> "They do within double quotes: \r\n\t\b" => "They do within double quotes: \r\n\t\b" Aaron out.