Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Is it possible to convert string_t to string?

$
0
0
Hi tmengCW

Yes most of the APIs in the C++ Rest SDK operate on the type utility::string_t. This is a platform dependent string type. It is a typedef to a std::wstring containing UTF-16 on Windows and a std::string containing UTF-8 on other platforms. We have an easy to use set of string conversion functions under the utility::conversions namespace that you should take a look at.

If you have a json::value that you know is a string value type then you could retrieve it and convert it to a std::string with something like the following:
std::string str = ::utility::conversions::to_utf8string(myJsonValue.as_string());
Steve

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>