Possible duplicate:How to convert byte * to std :: string in C ++?
Hi guys,
I am on an embedded device and trying to get a message. This message is specified by the character const uint8* dataand its length.uint8 len
const uint8* data
uint8 len
now i need std :: string to output my data.
If you do not want to convert the encoding, this will work:
std::string s( data, data+len );
If you want to convert UTF-8 to any system encoding used by your platform, you need to use some tools for a specific platform.
uint8* ? , :
uint8*
std::string mystring(data);
sizeof (uint8)!= sizeof (char) :
std::string output( len, 0 ); for ( size_t i = 0; i < len; ++i ) output[ i ] = static_cast<char>( data[ i ] );
Source: https://habr.com/ru/post/1781649/More articles:Global variable on asp.net - global-variablesHow can I use namespaces in C ++ files? - c ++Scalability php applications - performancewhy we store -D in others c Flags in xcode - iphone-sdk-3.0Need help splitting MVC - phpSplitting a string into a list according to a given format - pythonSystem.Threading.Timers VS Windows Service VS Schedule Appointment - .netкак перейти к середине единственного связанного списка на одной итерации? - javaВыберите таблицу или массив для каждой строки более крупного запроса выбора - sqlHow to create an NSPredicate to search for records with a leading numeric value? - objective-cAll Articles