JSON 指定“任何 UNICODE 字符”?
也许这只是我对unicode的不熟悉,所以如果我错了,请纠正我。
查看 http://json.org/,规范规定字符串可以包含“任何 UNICODE 字符”,但是这让我很困惑。
- JSON是一种通信格式 正确的?其核心是, 一切都必须转化为 字节。
- 相比之下,UNICODE 是 逻辑格式并且必须编码为 可以传送的吧?
那么他们的意思是什么?
Maybe this is just my unfamiliarity with unicode, so please correct me if I'm mistaken.
Looking at http://json.org/, the spec says that a string can include "any UNICODE character", but this confuses me.
- JSON is a communication format
correct? At the core of it,
everything must translate down to
bytes. - In contrast, UNICODE is a
logical format and must be encoded to
be able to transmit it, right?
So what did they mean there?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 RFC:
From the RFC:
JSON 是一种序列化格式,可以包含 UNICODE 字符。此 unicode 字符串的字节表示通常通过线路发送,通常通过 HTTP 协议发送,该协议使用 HTTP 标头来指定客户端的编码(UTF-8)。
JSON is a serialization format which can include UNICODE characters. The byte representation of this unicode string is usually sent over the wire, normally through the HTTP protocol which uses HTTP headers to specify the encoding to the client which is UTF-8.
您是对的,所有内容都必须转换为字节,并且通常通过 UTF(Unicode 转换格式)进行。 JSON RFC 在 第 3 节中解释了如何判断 UTF 是什么用过的。
You're correct that everything must translate into bytes, and usually that usually occurs through a UTF (Unicode Transformation Format). The JSON RFC explains in section 3 how to tell what UTF is being used.