no suitable user-defined conversion from utility::string_t to std::string

為{幸葍}努か 提交于 2019-11-30 20:36:32

If you see the documentation for C++ REST SDK from github, you'll find a typedef

C++ Rest SDK - utility Namespace Reference

typedef std::string     string_t;

So no need to convert it. Both are same types.

Depending on what platform you are compiling for, the utility::string_t type will be typedef'd to either std::wstring (on Windows) or std::string (on Linux/OSX).

To get a classic utf-8 std::string regardless of platform, take a look at utility::conversions::to_utf8string.

reference documentation

On Windows Phone 8.1 there is this define:

typedef std::wstring     string_t;

I used this:

string_t toStringT = U("sample");
std::string fromStringT(toStringT.begin(), toStringT.end());

or:

std::string fromStringT(conversions::to_utf8string(toStringT));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!