首页 > 解决方案 > cpprest 带有日文字符?

问题描述

以下代码:

auto nullValue = json::value::null();
std::string searchText = conversions::to_utf8string("michael");
make_request(client, methods::GET, nullValue, searchText);

返回 json 数据:

{"data":[
  {
    "_id":172,"name":"Michael Edano","profile_picture":null
  }],
  "success":true
}

但是如果我输入日文字符串:

auto nullValue = json::value::null();
std::string searchText = conversions::to_utf8string("北島 美奈");
make_request(client, methods::GET, nullValue, searchText);

输出是:

provided uri is invalid: /api/authenticate/searchStaffs/?? ??

但预期的输出是:

{"data":[{"_id":12,"name":"北島 美奈","profile_picture":null}],"success":true}

这是什么原因?

标签: c++cpprest-sdkcjk

解决方案


你需要做的就是

auto nullValue = json::value::null();
std::wstring searchText =L"北島 美奈";
make_request(client, methods::GET, nullValue, searchText);

希望它有帮助


推荐阅读