From: Xavier Noria Date: 2008-03-26T05:02:36+09:00 Subject: Re: Is possible Ruby to use CRLF instead of LF? On Mar 25, 2008, at 17:50 , Iņaki 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 only LFs as long as the file has the newline conventions of the runtime platform. That's because the Ruby interpreter itself reads the program as a text file in text mode. If you want to force CRLF in a here-document you can use a trick like this (off the top of my head): example = <