profile
viewpoint

Ask questionsAccept 报错,编译通不过,当使用UTF16的时候

代码的作用是把v, 转换成 一个UTF16的字符串, 但是编译不通过VS2015

    rapidjson::GenericValue<rapidjson::UTF16<> > v;	
v.SetString(L"你好");
rapidjson::GenericStringBuffer< rapidjson::UTF16<> > wbuffer;
rapidjson::Writer< rapidjson::GenericStringBuffer< rapidjson::UTF16<> > > writer(wbuffer);
v.Accept(writer);  // 编译出错
wstring s = wbuffer.GetString();
Tencent/rapidjson

Answer questions miloyip

#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
#include <string>

using namespace std;
using namespace rapidjson;

int main() {
   GenericValue<rapidjson::UTF16<> > v; 
    v.SetString(L"你好");
    GenericStringBuffer<UTF16<> > wbuffer;
    Writer<GenericStringBuffer<UTF16<> >, UTF16<>, UTF16<> > writer(wbuffer);
    v.Accept(writer);
    wstring s = wbuffer.GetString();
}
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