From: MonkeeSage Date: 2007-12-18T03:31:17+09:00 Subject: Re: Backslashes in Command Line Arguments On Dec 17, 11:51 am, Joseph Pecoraro wrote: > > It does get a newline character...try looking at "\n"[0] (or if you're > > using 1.9, "\n".ord)...you'll notice it's the ascii ordinal 10...aka > > "newline". That was Robert's point. #inspect (and by proxy #p) > > represent non-printing characters as their escaped symbols so that you > > can actually see them. Try entering this in irb and notice the > > difference betwen the input string and that printed by #p... > > It seems both of you have missed the point of my question. The input is > coming into Ruby from the Command Line. > > Of course "\n"[0] is going to be a newline... IT is a newline. But if > you read the above posts you will see what I was talking about: > > $ ruby example.rb "\n" > > Does not result in YOUR "\n", it results in "\\n" which was part of MY > problem, which Sebastian showed me how to solve. > > I know I have the literal string referring to a Backslash N and not a > Newline because I used #p... > > "\n" #=> newline > "\\n" #=> backslash n > -- > Posted viahttp://www.ruby-forum.com/. Ah-ha. I understood your original problem, but I was confused about your reasoning for using #p...by 'send "\n"' in your previous post I (mis-)understood 'type "\n" in a script', and thought you were saying that you used #p because you wanted to see whether ruby would output a literal newline or keep the two-byte escape sequence. Sorry about that! Regards, Jordan