From: Bill Kelly Date: 2005-12-11T11:10:29+09:00 Subject: Re: How to preserve line endings in strings with YAML? From: "Tom Payne" > > YAML.load("abc\r\n".to_yaml) # => "abc\n" ("\r" lost) > YAML.load("\r\n".to_yaml) # => "" ("\r\n" lost) > YAML.load("\n".to_yaml) # => "" ("\n" lost) > > My question is: how can I configure YAML to preserve my line endings? > I'm using Ruby 1.8.4-preview2 and have Googled for a solution without > success. Note that the :UseBlock option to to_yaml does not help. On my system, ruby 1.8.2 (2004-12-25) [i386-mswin32], the first two seemed to work: >> YAML.load("abc\r\n".to_yaml) => "abc\r\n" >> YAML.load("\r\n".to_yaml) => "\r\n" But the third didn't: >> YAML.load("\n".to_yaml) => " " I guess if all else fails you could: >> CGI.unescape(YAML.load(CGI.escape("\n").to_yaml)) => "\n" Regards, Bill