title: How to iterate Unicode characters? (Not codepoints)
body: <p>I'd like to iterate through Unicode characters, gobbling up all combining characters that follow the initial code point.</p>
  
  <p>This is what I have so far, but it acts really weird for some random Unicode sequences I tried: (for example, when I pass it things like "a̔" (U+0061 LATIN SMALL LETTER A followed by U+0314 COMBINING REVERSED COMMA ABOVE) it sees it as two characters rather than one. Other things, like "e︠" (U+0065 LATIN SMALL LETTER E followed by  U+FE20 COMBINING LIGATURE LEFT HALF) are seen as one character)</p>
  
  <pre class="lang-c prettyprint-override"><code>int COMBINING[] = {
      0x0300, 0x036F,
      0x1DC0, 0x1DFF,
      0x20D0, 0x20FF,
      0xFE20, 0xFE2F,
      0 //sentinel
  };
  
  utf8_index_t ut_nextchar(utf8_t source, utf8_index_t curr)
  {
      int c = decode_cp(source, &amp;curr);
      int comb = 0;
      if (c == 0)
          return -1;
      while (COMBINING[comb] != 0)
      {
          for (comb = 0; COMBINING[comb] != 0; comb += 2)
          {
              if (c &gt;= COMBINING[comb] &amp;&amp; c &lt;= COMBINING[comb + 1])
              {
                  c = decode_cp(source, &amp;curr);
                  if (c == 0)
                      return -1;
                  break;
              }
          }
      }
      return curr;
  }
  </code></pre>