是否可以在 YAML 多行字符串中使用 Unicode 字符转义(例如 \u2009
)?
this_escape_works: "foo\u2009bar"
this_escape_doesnt: >
foo\u2009bar
最佳答案
根据the YAML1.2 spec标量的双引号样式是:
the only style capable of expressing arbitrary strings, by using “\” escape sequences. This comes at the cost of having to escape the “\” and “"” characters.
所以折叠标量不支持转义,你必须这样做
this_escape_works: "foo\u2009bar"
this_escape_doesnt: "foo\u2009bar\n"
请注意,与 @nj_ 的声明相反,折叠指示符 >
(它不是运算符)一般不会“换行符变成空格”,当然也不会用于 the final line break
关于unicode - 如何在 YAML 多行字符串中进行 Unicode 转义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35746109/