How to convert std :: string to std :: vector <uint8_t>?

The data format required to save games in the services of Google gaming games is std::vector<uint8_t> , as indicated in the Data Formats section: https://developers.google.com/games/services/cpp/savedgames

I assume that the vector is some kind of array of bytes. It's right? So how to convert std::string to std::vector<uint8_t> ?

+6
source share
1 answer

std::vector has a constructor for this purpose only:

 std::string str; std::vector<uint8_t> vec(str.begin(), str.end()); 
+13
source

Source: https://habr.com/ru/post/1014208/


All Articles