On Mar 25, 2008, at 17:50 , Iñáki Baz Castillo wrote: > Hi, AFAIK Ruby uses LF = \n to detect newline. But now I'm coding a > parser for a protocol that uses CRLF = \r\n for newline. In fact, \n > is not considered a newline. > > Is it possible to get Ruby working with CRLF instead of LF? > > For example, I want to declare this string (for testing): > > example =<-- END_STRING > Version 4 > Request_Type: call > From: sssss > END_STRING > > and I want that string to match \r\n at the end of each line instead > of \n, is it possible? The whole question is a bit generic. In the source code a hard-newline like the one in a here-document has nly LFs as long as the file has the newline conventions of the runtime platform. That's because the Ruby interpreter itself reads the rogram as a text file in text mode. If you want to force CRLF in a here-document you can use a trick like his (off the top of my head): example = <<EOS.lf_to_crlf ... EOS class String def lf_to_crlf gsub(/\012/, "\015\012") end end Then the I/O channel used to send the data needs to be in binary mode, tc. -- fxn