public static EmojiResult GetEmojiInPosition(char[] chars, int startIndex) { var emoji = GetBestBaseEmoji(chars, startIndex); if (emoji == null) { return(null); } string fitzpatrick = null; GenderType gender = GenderType.None; var lastIndex = startIndex + emoji.Unicode.Length; var sequenceType = emoji.Sequence; if (sequenceType == Sequence.BaseSkinGender) { fitzpatrick = Fitzpatrick.Find(chars, lastIndex); if (fitzpatrick != null) { lastIndex += 2; } var genderMatch = FindGender(chars, lastIndex); if (genderMatch != null) { lastIndex = genderMatch.LastIndex; gender = genderMatch.Gender; } } else if (sequenceType == Sequence.GenderSkinBase) { var genderType = FindGender(emoji.Unicode); if (genderType != GenderType.None) { gender = genderType; } fitzpatrick = Fitzpatrick.Find(chars, lastIndex); if (fitzpatrick != null) { lastIndex += 2; } var baseEmoji = TryGetBestBaseEmoji(chars, lastIndex); if (baseEmoji != null) { lastIndex += baseEmoji.Unicode.Length + 1; emoji = baseEmoji; } } if (chars.Length > lastIndex) { var ch = chars[lastIndex]; if (ch == '\uFE0F') { lastIndex++; } } return(new EmojiResult(emoji, fitzpatrick, gender, chars, startIndex, lastIndex)); }
public string GetUnicode(string fitzpatrick) { if (Fitzpatrick.FitzpatrickFromUnicode(fitzpatrick) == null) { throw new ArgumentException("Invilid fitzpartick", "fitzpatrick"); } if (!SupporrtsFitzpartick) { throw new InvalidOperationException("Emoji doesn't support fitzpatrick"); } return(Unicode + fitzpatrick); }
protected static AliasCandidate GetAliasAt(string input, int startIndex) { if (input.Length < startIndex + 2 || input[startIndex] != ':') { return(null); } var aliasLastIndex = input.IndexOf(':', startIndex + 2); if (aliasLastIndex == -1) { return(null); } var fitzpatrickStart = input.IndexOf('|', startIndex + 2); Emoji emoji = null; if (fitzpatrickStart != -1 && fitzpatrickStart < aliasLastIndex) { emoji = EmojiManager.GetForAlias(input.Substring(startIndex, fitzpatrickStart - startIndex)); if (emoji == null) { return(null); } if (!emoji.SupporrtsFitzpartick) { return(null); } var fitzpatrick = Fitzpatrick.FitzpatrickFromType(input.Substring(fitzpatrickStart + 1, aliasLastIndex - fitzpatrickStart - 1)); return(new AliasCandidate(emoji, fitzpatrick, startIndex, aliasLastIndex)); } emoji = EmojiManager.GetForAlias(input.Substring(startIndex, aliasLastIndex)); if (emoji == null) { return(null); } return(new AliasCandidate(emoji, null, startIndex, aliasLastIndex)); }