Reputation: 886
I was trying to create a client in c++ for a web service using a Service Model Metadata Utility Tool, I have established the communication between the two endpoints, but at the client side I receive a wchar_t*
, how can i convert it to a string?
Note: the server side is using encoding of UTF-8.
Upvotes: 2
Views: 5013
Reputation: 417
Use this simple function:
std::string wchar2string(wchar_t* str)
{
std::string mystring;
while( *str )
mystring += (char)*str++;
return mystring;
}
I hope that this function can help you!
Upvotes: 4
Reputation: 1024
You can use std::wstring
which has a constructor that takes wchar_t*
.
Upvotes: 3