From: "Bermejo, Rodrigo" Date: 2003-07-16T07:52:43+09:00 Subject: Re: how to insert a carriage return in a string You should use doublequotes to build your strings Check the differences btw " & ' irb.log(main):001:0> f=File.open "tmp" ,"w" irb.log(main):002:0> myString = 'a\nb' "a\\nb" irb.log(main):003:0> f << myString irb.log(main):005:0> f.close irb.log(main):007:0> r=`cat tmp` #Or File.open "a\\nb" irb.log(main):011:0> myString = "a\nb" "a\nb" irb.log(main):012:0> f=File.open "tmp" ,"w" irb.log(main):013:0> f << myString irb.log(main):014:0> f.close irb.log(main):016:0> r=`cat tmp` #Or File.open "a\nb" then you can >>> r.split("\n").each {| line | p line } -ronnie. Emmanuel Touzery wrote: >Hello, > > definitely a very newbie question... i have strings, possibly with >carriage returns in my application, and i want to save them with '\n' in >litteral in my file (so that i'm guaranteed this string is on at most one >line), and then get back "\n" when deserializing. > > But i don't quite get it for the deserialization part: > >irb(main):001:0> myString = 'a\nb' >"a\\nb" >irb(main):002:0> myString.gsub('\n', "\n") >"a\\nb" >irb(main):003:0> myString.gsub("\\n", "\n") >"a\\nb" > >obviously i want to get "a\nb" (from "a\\nb"). How I am supposed to do that? > >thank you, > >emmanuel > > > > -- General Electric - CIAT Advanced Engineering Center ________________________________________ Rodrigo Bermejo Information Technologies. Dial-comm : *879-0644 Phone :(+52) 442-196-0644 mailto:rodrigo.bermejo@ps.ge.com