ruby write newline character to file but do not interpret as a true newline

Posted by thomas on Stack Overflow See other posts from Stack Overflow or by thomas
Published on 2010-06-10T13:49:54Z Indexed on 2010/06/10 13:52 UTC
Read the original article Hit count: 382

Filed under:
|

I am trying to write a ruby string to a file in such a way that any newline characters embedded in the string remain embedded. This is being written out to a file which will then be processed by another tool.

An example is below.

I want this: 1 [label="this is a\ntest"] \n (second \n is a true newline)
I have tried this: string = '1 [label="this is a\ntest"]' + "\n"

Any thoughts?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about string