JSON指定"任何UNICODE字符"?

buk*_*zor 7 unicode encoding json

也许这只是我对unicode的不熟悉,所以如果我弄错了,请纠正我.

看看http://json.org/,规范说一个字符串可以包含"任何UNICODE字符",但这让我很困惑.

  • JSON是一种通信格式正确吗?在它的核心,一切都必须转化为字节.
  • 相比之下,UNICODE是一种逻辑格式,必须进行编码才能传输它,对吧?

那他们的意思是什么?

cob*_*bal 16

来自RFC:

3.  Encoding

   JSON text SHALL be encoded in Unicode.  The default encoding is
   UTF-8.

   Since the first two characters of a JSON text will always be ASCII
   characters [RFC0020], it is possible to determine whether an octet
   stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
   at the pattern of nulls in the first four octets.

           00 00 00 xx  UTF-32BE
           00 xx 00 xx  UTF-16BE
           xx 00 00 00  UTF-32LE
           xx 00 xx 00  UTF-16LE
           xx xx xx xx  UTF-8

  • 当人们说"用Unicode编码"时,我总是感到困惑,因为(据我理解),Unicode是一个字符集,而不是编码.不应该是"应该使用Unicode字符集,默认编码为UTF-8"?我很惊讶在RFC中看到这样的事情. (2认同)