From: Xavier Noria Date: 2006-08-01T01:09:15+09:00 Subject: Re: Does Ruby need a "line separator" class? On Jul 31, 2006, at 5:40 PM, Wes Gamble wrote: > I've run into a problem where Ruby can't handle newlines on Windows > because the regexp is explicitly looking for \n and not \r\n. It shouldn't look for CRLFs. The rules of the game in languages that inherit the newline normalization approach from C (those include C++, and Perl, for instance, but not Java) are that if you work in text mode and the text file follows runtime conventions, you only read and print "\n"s. That's because there's an intermediate IO layer that transforms CRLF into LF in CRLF platforms on reading, and LF back to CRLF on writing. In Java this is handled in a different way, "\n" is not portable in Java. Portable code in Java uses method calls like println. But in Ruby a portable regexp that assumes text mode and data with the runtime platform conventions for newlines have to use "\n", no CR ever gets into the string. -- fxn