c++ - 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}
这是什么原因?
解决方案
你需要做的就是
auto nullValue = json::value::null();
std::wstring searchText =L"北島 美奈";
make_request(client, methods::GET, nullValue, searchText);
希望它有帮助
推荐阅读
- mongodb - 为什么mongoose模式类型是double,但是插入值时,mongo中的类型是int32?
- excel - 如何在查找表数组是动态的情况下使用 vlookup 函数?
- ios - 何时使用 Swift 的 fatalError()、precondition() 或 assertion() 函数?
- postgresql - Postgres 多列索引需要很长时间才能完成
- java - 如何检查数组中匹配的 int 值/字符串值?
- android - 如何根据姓名按字母顺序对联系人数据进行排序,当联系人没有姓名时,请改用电子邮件?
- javascript - 我在一个字符串数组上调用了 reduce。为什么这会产生一个数字?
- wordpress - 注意:试图在 WordPress save_post 动作钩子上获取非对象的属性
- selenium - 无法使用 crontab (MAC) 执行 selenium-side-runner
- javascript - 使用 Notification.image 或 Notification.icon