What about (encoding)[http://www.ruby-doc.org/core-1.9.3/String.html#method-i-encode] it with :universal_newline?