Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 javascript 中,尤其是在 JSON 中,我们可以用转义序列或直接的 unicode 字符串来表示 unicode 字符。
两者有何不同?使用一个比另一个有任何实际意义或陷阱吗?
转义序列使用 ASCII 字符,因此可以表示,而不必担心 JS 或 JSON 传输/保存使用的编码。每个编码字符需要更多字节。人类通过查看源代码来阅读它们并不容易。
使用 Unicode 编码(如 UTF-8)时,以上都不是真的。