title: How to compare and convert emoji characters in C#
body: <p>I am trying to figure out how to check if a string contains a specfic emoji. For example, look at the following two emoji:</p>
  
  <p>Bicyclist:  <a href="http://unicode.org/emoji/charts/full-emoji-list.html#1f6b4" rel="noreferrer">http://unicode.org/emoji/charts/full-emoji-list.html#1f6b4</a></p>
  
  <p>US Flag: <a href="http://unicode.org/emoji/charts/full-emoji-list.html#1f1fa_1f1f8" rel="noreferrer">http://unicode.org/emoji/charts/full-emoji-list.html#1f1fa_1f1f8</a></p>
  
  <p>Bicyclist is <code>U+1F6B4</code>, and the US flag is <code>U+1F1FA U+1F1F8</code>.</p>
  
  <p>However, the emoji to check for are provided to me in an array like this, with just the numerical value in strings:</p>
  
  <pre><code>var checkFor = new string[] {"1F6B4","1F1FA-1F1F8"};
  </code></pre>
  
  <p>How can I convert those array values into actual unicode characters and check to see if a string contains them?</p>
  
  <p>I can get something working for the Bicyclist, but for the US flag I'm stumped.</p>
  
  <p>For the Bicyclist, I'm doing the following:</p>
  
  <pre><code>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);
  </code></pre>
  
  <p>But this will not work with the US Flag because of the multiple code points.</p>