How to iterate through various emojis

is it possible to iterate through different emojis like we iterate through character

1 Like

Do you want to find all emojis in a string, or list all emojis?

1 Like

list all emojis

1 Like

The code points of emoji are not just an increasing sequence of numbers - some even consist of several code points. The easiest would probably be to find a list somewhere and include it using include_str. You can then iterate through the list using the ordinary string iteration methods.

2 Likes

The rust-unic project has a list of emoji characters you may be able to use.

Otherwise you may want to check out BurntSushi's ucd-generate tool.

2 Likes

I am not sure I am getting the question right, but is this what you are looking for?

fn main() {
   let str_of_emojis = "😘🤗🦀";

   for emoji in str_of_emojis.chars() {
       println!("{}", emoji);
   }
}

So, in the end, it is the same as iterating over any other unicode character.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.