13

Is it possible to use Unicode character escaping (e.g. \u2009) in YAML multiline strings?

this_escape_works: "foo\u2009bar"
this_escape_doesnt: >
  foo\u2009bar
Sampo
  • 4,308
  • 6
  • 35
  • 51

1 Answers1

15

As per the YAML1.2 spec double quoted style for scalars is:

the only style capable of expressing arbitrary strings, by using “\” escape sequences. This comes at the cost of having to escape the “\” and “"” characters.

So folded scalars do not support escaping and you have to do

this_escape_works: "foo\u2009bar"
this_escape_doesnt: "foo\u2009bar\n"

Please note that contrary to @nj_'s claim the folding indicator > (it is not an operator) doesn't do "newlines become spaces" in general and certainly not for the final line break

Anthon
  • 69,918
  • 32
  • 186
  • 246