Ejemplo n.º 1
0
        private static string UnicodeToShortnameCallback(Match match)
        {
            // check if the emoji exists in our dictionaries
            var unicode   = match.Groups[1].Value;
            var codepoint = ToCodePoint(unicode);

            if (CODEPOINT_TO_SHORTNAME.ContainsKey(codepoint))
            {
                return(CODEPOINT_TO_SHORTNAME[codepoint]);
            }

            // we didn't find a replacement so just return the entire match
            return(match.Value);
        }
Ejemplo n.º 2
0
        private static string AsciiToShortnameCallback(Match match)
        {
            // check if the emoji exists in our dictionaries
            var ascii = match.Value;

            if (ASCII_TO_CODEPOINT.ContainsKey(ascii))
            {
                var codepoint = ASCII_TO_CODEPOINT[ascii];
                if (CODEPOINT_TO_SHORTNAME.ContainsKey(codepoint))
                {
                    return(CODEPOINT_TO_SHORTNAME[codepoint]);
                }
            }
            // we didn't find a replacement so just return the entire match
            return(match.Value);
        }
Ejemplo n.º 3
0
        private static string UnicodeToImageCallback(Match match, bool unicodeAlt, bool svg, bool sprites, bool awesome)
        {
            // check if the emoji exists in our dictionaries
            var codepoint = ToCodePoint(match.Groups[1].Value);

            if (CODEPOINT_TO_SHORTNAME.ContainsKey(codepoint))
            {
                var    shortname = CODEPOINT_TO_SHORTNAME[codepoint];
                string alt       = unicodeAlt ? ToUnicode(codepoint) : shortname;
                if (awesome)
                {
                    return(string.Format(@"<i class=""e1a-{0}""></i>", shortname.Replace("_", "-").Replace(":", "")));
                }
                else if (svg)
                {
                    if (sprites)
                    {
                        return(string.Format(@"<svg class=""emojione""><description>{0}</description><use xlink:href=""{1}#emoji-{2}""></use></svg>", unicodeAlt ? alt : shortname, ImagePathSvgSprites, codepoint));
                    }
                    else
                    {
                        return(string.Format(@"<object class=""emojione"" data=""{0}{1}.svg{2}"" type=""image/svg+xml"" standby=""{3}"">{3}</object>", ImagePathSvg, codepoint, CacheBustParam, unicodeAlt ? alt : shortname));
                    }
                }
                else
                {
                    if (sprites)
                    {
                        return(string.Format(@"<span class=""emojione emojione-{0}"" title=""{1}"">{2}</span>", codepoint, shortname, unicodeAlt ? alt : shortname));
                    }
                    else
                    {
                        return(string.Format(@"<img class=""emojione"" alt=""{0}"" src=""{1}{2}.png{3}"" />", unicodeAlt ? alt : shortname, ImagePathPng, codepoint, CacheBustParam));
                    }
                }
            }

            // we didn't find a replacement so just return the entire match
            return(match.Value);
        }