GithubHelp home page GithubHelp logo

Comments (4)

miloyip avatar miloyip commented on May 17, 2024

虽然是一個 char* ,但不单是 null-terminated string。可以用 lept_get_string_length() 获取真实長度。

可用这两个数据调用此 std::string constructor:

basic_string::basic_string( const CharT* s,
              size_type count, 
              const Allocator& alloc = Allocator() );

JSON 语法是接受 \u0000 的,转成 UTF-8 就是 '\0'

from json-tutorial.

Yuan-Hang avatar Yuan-Hang commented on May 17, 2024

在请问一下叶老师,我自己写的时候使用的std::string,这样和我们教程中用char*实现比较起来有什么优劣势呢?使用std::string简化了一些代码,但是效率会不会更低一些呢?

from json-tutorial.

miloyip avatar miloyip commented on May 17, 2024

这个问题不好答。要看你用了 std::string 中什么函数。最理想的情况下性能和 C 一样。

from json-tutorial.

be5invis avatar be5invis commented on May 17, 2024

如果用 c string 可以试试编码成 C0 80.
单独的代理项也可以「强行」编码成三个字节。

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.