Ejemplo n.º 1
0
        /// <summary>
        /// Shortnames to unicode callback.
        /// </summary>
        /// <param name="match">The match.</param>
        /// <returns>Returns the converted string</returns>
        private static string ShortNameToUnicodeCallback(Match match)
        {
            // check if the emoji exists in our dictionaries
            var shortName = match.Value;

            return(SHORTNAME_TO_CODEPOINT.ContainsKey(shortName)
                       ? ToUnicode(SHORTNAME_TO_CODEPOINT[shortName])
                       : match.Value);

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

            if (SHORTNAME_TO_CODEPOINT.ContainsKey(shortname))
            {
                // convert codepoint to unicode char
                return(ToUnicode(SHORTNAME_TO_CODEPOINT[shortname]));
            }

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

            if (SHORTNAME_TO_CODEPOINT.ContainsKey(shortname))
            {
                var codepoint = SHORTNAME_TO_CODEPOINT[shortname];
                if (CODEPOINT_TO_ASCII.ContainsKey(codepoint))
                {
                    return(CODEPOINT_TO_ASCII[codepoint]);
                }
            }

            // we didn't find a replacement so just return the entire match
            return(match.Value);
        }
Ejemplo n.º 4
0
        private static string ShortnameToImageCallback(Match match, bool unicodeAlt, bool svg, bool sprites, bool awesome)
        {
            // check if the emoji exists in our dictionaries
            var shortname = match.Value;

            if (SHORTNAME_TO_CODEPOINT.ContainsKey(shortname))
            {
                var    codepoint = SHORTNAME_TO_CODEPOINT[shortname];
                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);
        }