Possible Duplicate:
How to Convert Byte* to std::string in C++?
I'm on an embedded device and try to receive a message.
This message is given by a const uint8_t* data
and its length size_t len
.
Now I need a std::string
to output my data.
If you don't want to convert the encoding, this will work:
std::string s( data, data+len );
If you want to convert UTF-8 into whatever system encoding is used by your platform, you need to use some platform-specific means.
Is your uint8*
string null-terminated? If so, you can just do:
std::string mystring(data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With