I'm trying to take a string of emojis and split them into a vector of each emoji
Given the string:
std::string emojis = "πππ¦πππππ€£";
I'm trying to get:
std::vector<std::string> splitted_emojis = {"π", "π", "π¦", "π", "π", "π", "π", "π€£"};
Edit
I've tried to do:
std::string emojis = "πππ¦πππππ€£";
std::vector<std::string> splitted_emojis;
size_t pos = 0;
std::string token;
while ((pos = emojis.find("")) != std::string::npos)
{
token = emojis.substr(0, pos);
splitted_emojis.push_back(token);
emojis.erase(0, pos);
}
But it seems like it throws terminate called after throwing an instance of 'std::bad_alloc'
after a couple of seconds.
When trying to check how many emojis are in a string using:
std::string emojis = "πππ¦πππππ€£";
std::cout << emojis.size() << std::endl; // returns 32
it returns a bigger number which i assume are the unicode data. I don't know too much about unicode data but i'm trying to figure out how to check for when the data of an emoji begins and ends to be able to split the string to each emoji