profile
viewpoint

Ask questionsJSON字符串包含生僻中文字符无法解析

JSON字符串包含生僻中文字符无法解析,正常汉字可以解析

Tencent/rapidjson

Answer questions miloyip

不能重现:

in.json

{"賊":1}

a.cpp:

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/filereadstream.h"
#include "rapidjson/filewritestream.h"

using namespace rapidjson;

int main() {
    Document d;

    {
        FILE* fp = fopen("in.json", "r");
        char buffer[256];
        FileReadStream frs(fp, buffer, sizeof(buffer));
        d.ParseStream(frs);
        fclose(fp);
    }

    {
        FILE* fp = fopen("out.json", "w");
        char buffer[256];
        FileWriteStream fws(fp, buffer, sizeof(buffer));
        Writer<FileWriteStream> writer(fws);
        d.Accept(writer);
        fclose(fp);
    }
}
$g++ -I ~/github/rapidjson/include a.cpp && ./a.out && cat out.json
{"賊":1}

Archive.zip

useful!

Related questions

是否支持流式解析以及多个json分离解析 hot 1
是否支持流式解析以及多个json分离解析 hot 1
RapidJSON causes cc1plus: internal compiler error: Segmentation fault - rapidjson hot 1
GenericMemberIterator::Iterator implicitly declared private when RAPIDJSON_NOMEMBERITERATORCLASS is defined hot 1
Always gets a core dump while creating json string (rapidjson) hot 1
Bazel Support hot 1
Syntax typo in tutorial hot 1
是否支持流式解析以及多个json分离解析 hot 1
作者你好,我 想请教一下,这个框架是否能够将变量中文stirng 转成wchar_t? 在文档只看到定量 hot 1
travis on windows hot 1
Added headers to my project and got thousands of errors hot 1
Added headers to my project and got thousands of errors hot 1
想要的反斜杠 \. 无法表示,否则JSON解析出错 hot 1
Assertion `stack_.GetSize() == sizeof(ValueType)' failed hot 1
source:https://uonfu.com/
Github User Rank List