I am trying to figure out how to check if a string contains specfic emoji. For example, look at the following two emoji:
Bicyclist: http://unicode.org/emoji/charts/full-emoji-list.html#1f6b4
USA flag: http://unicode.org/emoji/charts/full-emoji-list.html#1f1fa_1f1f8
Bicyclist U+1F6B4 , and the US flag U+1F1FA U+1F1F8 .
However, emoji for verification is provided to me in an array like this, with only a numeric value in the lines:
var checkFor = new string[] {"1F6B4","1F1FA-1F1F8"};
How can I convert these array values ββto actual Unicode characters and check if the string contains them?
I can get something that works for a Bicyclist, but for the US flag, I'm at a standstill.
For Bicyclist, I do the following:
const string comparisonStr = "..."; //some string containing text and emoji var hexVal = Convert.ToInt32(checkFor[0], 16); var strVal = Char.ConvertFromUtf32(hexVal); //now I can successfully do the following check var exists = comparisonStr.Contains(strVal);
But this will not work with the US flag due to the many code points.
source share