From: Robert Klemme Date: 2003-07-16T20:47:28+09:00 Subject: Re: basic doubts on "\n" "Xavier Noria" schrieb im Newsbeitrag news:200307161202.31854.fxn@hashref.com... > I am trying to get the picture about how "\n" works in Ruby. > > Since this is somewhat difficult to concrete in a single question I have > broken the issue in a few ones. Let's see how it works. > > * Does "\n" play the role of logical newline? In a broad sense, if that > was the case portable line-oriented code would use "\n" as newline for > reading and writing through non-binmoded streams. (True in Perl, false > in Java.) Yes. But you can change that either by setting $/ to something else or by using IO#each or IO#each_line with a string used as record (i.e. line) separator. > * Is "\n".length == 1 no matter the platfrom? (True in Perl, true in > Java.) Yes. > * Does "\n" == "\x0a" hold no matter the platform? (False in Perl, true > in Java.) I think so. > * Does "\n" get translated by the underlying I/O system back and forth > to native newlines in non-binmoded streams? (True in Perl, false in > Java.) I think so. On win platform i always receive lines with a single "\n" at the end, although the OS uses "\r\n". > Thank you very much, and regards from warm Barcelona, Warm regards from warm Paderborn to warm Barcelona robert