title: How to break a string over multiple lines and preserve spaces in YAML?
body: <p>Please note, that the question is similar like <a href="https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines">this one</a>, but still different so that those answers won't solve my problem:</p>
  
  <ul>
  <li>For insertion of control characters like e.g. <code>\x08</code>, it seems that I have to use double quotes <code>"</code>.</li>
  <li>All spaces needs to be preserved exactly as given. For line breaks I use explicitly <code>\n</code>.</li>
  </ul>
  
  <p>I have some string data which I need to store in YAML, e.g.:</p>
  
  <ul>
  <li><code>"  This  is  my  quite  long  string  data  "</code></li>
  <li><code>"This is my quite long string data"</code></li>
  <li><code>"This_is_my_quite_long_string_data"</code></li>
  <li><code>"Sting data\nwhich\x08contains control characters"</code></li>
  </ul>
  
  <p>and need it in YAML as something like this:</p>
  
  <pre><code>Key: "  This  is  my" +
       "  quite  long " +
       " string  data  "
  </code></pre>
  
  <p>This is no problem as long as I stay on a single line, but I don't know how to put the string content to multiple lines.</p>
  
  <p>YAML block scalar styles (<code>&gt;</code>, <code>|</code>) won't help here, because they don't allow escaping and they even do some whitespace stripping, newline / space substitution which is useless for my case.</p>
  
  <p>Looks that the only way seems to be using double quoting <code>"</code> and backslashes <code>\</code>, like this:</p>
  
  <pre><code>Key: "\
    This is \
    my quite \
    long string data\
    "
  </code></pre>
  
  <p>Trying this in <a href="http://yaml-online-parser.appspot.com" rel="nofollow noreferrer">YAML online parser</a> results in <code>"This is my quite long string data"</code> as expected.</p>
  
  <p>But it unfortunately fail if one of the "sub-lines" has leading space, like this:</p>
  
  <pre><code>Key: "\
    This is \
    my quite\
     long st\
    ring data\
    "
  </code></pre>
  
  <p>This results in <code>"This is my quitelong string data"</code>, removed the space between the words <code>quite</code> and <code>long</code> of this example. The only thing that comes to my mind to solve that, is to replace the first leading space of each sub-line by <code>\x20</code> like this:</p>
  
  <pre><code>Key: "\
    This is \
    my quite\
    \x20long st\
    ring data\
    "
  </code></pre>
  
  <p>As I'd chosen YAML to have a best possible human readable format, I find that <code>\x20</code> a bit ugly solution. Maybe someone know a better approach?</p>
  
  <p>For keeping human readable, I also don't want to use <code>!!binary</code> for this.</p>