unicode - 如何在 YAML 多行字符串中进行 Unicode 转义?

标签 unicode yaml

是否可以在 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/

相关文章:

azure-devops - Azure DevOps YAML 管道手动干预作业与其他作业并行运行

java - Log4J2 Yaml 包级别

Java:从utf-8文件中读取字节

java字符串unicode代码点转换为字符

ansible - 为多个 import_playbook 包含文件中的变量

docker - kubectl:与服务器的连接被拒绝

c - C 中的小型 YAML/JSON 解析器

python - 标准库中的所有内容都会在 Python 3.0 中将字符串视为 unicode 吗?

c++ - 为什么我们从 MultiByte 转换为 WideChar?

java - 有人可以帮我解决这个问题吗?关于统一码