GithubHelp home page GithubHelp logo

解析字符串时,代理对不是针对 utf-16 才有的吗,这里是解析utf-8 的编解码,也需要处理代理对? about json-tutorial HOT 2 OPEN

hxler123 avatar hxler123 commented on June 7, 2024
解析字符串时,代理对不是针对 utf-16 才有的吗,这里是解析utf-8 的编解码,也需要处理代理对?

from json-tutorial.

Comments (2)

hxler123 avatar hxler123 commented on June 7, 2024

To escape an extended character that is not in the Basic Multilingual
Plane, the character is represented as a twelve-character sequence,
encoding the UTF-16 surrogate pair. So, for example, a string
containing only the G clef character (U+1D11E) may be represented as
"\uD834\uDD1E".

通过查阅rfc4627,json 规范中明确说明如果要转义超过bmp的字符,通过 UTF-16 surrogate pair 来转义。编码的时候会再转化为unicode code point,再将其通过utf-8 规则编码为二进制。 并不是以utf-16 来编码。

from json-tutorial.

hxler123 avatar hxler123 commented on June 7, 2024

我理解这应该是一种解析规则,在python中直接打印‘\uD834\uDD1E‘ 是会报错的,但是直接打印\U1D11E 是可以的。bash shell 中同样前者显示乱码,后者正常显示字符。

from json-tutorial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.