using System.Collections.Generic;
public static void Main()
string first = "\uD83D\uDC4Ar\uD83D\uDC4A\uD83D\uDC4A";
var list = new List<string>();
var itor = new EmojiIterator(first);
for (int i = 0; i < 20; i++)
Console.Write(list[i % list.Count] + "\r");
public class EmojiIterator
private int _head, _next;
private int _index, _length;
public EmojiIterator(string text)
public int Char { get { return _head; } }
public int Offset { get { return _index; } set { _index = value; _length = 0; _next = -1; } }
public int SequenceLength { get { return _length; } }
public string Sequence { get { return _text.Substring(_index, _length); } }
else if (_index < _text.Length)
_head = char.ConvertToUtf32(_text, _index);
private void GetNextChar()
_next = char.ConvertToUtf32(_text, _index + _length);
private void UseNextChar()
private void FindSequence(int headChar)
if (headChar > 0xffff && CheckFlagOrTagSequence(headChar))
private void CheckEmojiSequence()
if (_next >= 0x1f3fb && _next <= 0x1f3ff)
else if (_next == 0xfe0f)
else if (_next == 0x200d)
private bool CheckFlagOrTagSequence(int head)
if (IsRegionalIndicatorSymbol(head) && IsRegionalIndicatorSymbol(_next))
if (IsTagComponent(_next))
while (IsTagComponent(_next));
private static bool IsRegionalIndicatorSymbol(int ch)
return ch >= 0x1f1e6 && ch <= 0x1f1ff;
private static bool IsTagComponent(int ch)
return ch >= 0xe0020 && ch <= 0xe007e;