Regex reg = new Regex("[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u2600-\u27ff]");
MatchCollection match = reg.Matches(test_data);
string emoji_path = Server.MapPath("/Content/others/emoji.json");
StreamReader read = new StreamReader(emoji_path, Encoding.UTF8);
string json = read.ReadToEnd();
List<Emoji_g> emoji_list = JsonConvert.DeserializeObject<List<Emoji_g>>(json);
//StringBuilder sr = new StringBuilder();
//for (int i = 0; i < content.Length; i++)
//{
// sr.Append("\\u");
// sr.Append(((int)content[i]).ToString("X"));
//}
string emoji_str = string.Empty;
string emoji_value = string.Empty;
foreach (Match item in match)
{
StringBuilder sresult = new StringBuilder();
for (int i = 0; i < item.Length; i++)
{
sresult.Append(((int)item.Value[i]).ToString("X"));
}
Emoji_g emoji = emoji_list.Where(e => e.unicode == sresult.ToString()).FirstOrDefault();
Emoji_g e_teste = emoji_list.Where(e=>e.aliases[0]=="china").FirstOrDefault();
if (emoji != null)
{
emoji_str = string.Empty;
emoji_value = string.Empty;
}
else
{
emoji_str += sresult.ToString();
emoji_value += item.Value;
emoji = emoji_list.Where(e => e.unicode == emoji_str).FirstOrDefault();
if (emoji != null)
{
emoji_str = string.Empty;
emoji_value = string.Empty;
}
}
}
return Content(test_data);
Regex reg = new Regex("[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u2600-\u27ff]");
MatchCollection match = reg.Matches(content);
string emoji_path = Server.MapPath("/Content/others/emoji_ios6.json");
StreamReader read = new StreamReader(emoji_path, Encoding.UTF8);
string json = read.ReadToEnd();
List<Emoji_ios6> emoji_list = JsonConvert.DeserializeObject<List<Emoji_ios6>>(json);
//StringBuilder sr = new StringBuilder();
//for (int i = 0; i < content.Length; i++)
//{
// sr.Append("\\u");
// sr.Append(((int)content[i]).ToString("X"));
//}
foreach (Match item in match)
{
StringBuilder sresult = new StringBuilder();
for (int i = 0; i < item.Length; i++)
{
sresult.Append(((int)item.Value[i]).ToString("X"));
}
Emoji_ios6 emoji = emoji_list.Where(e => e.utf16 == sresult.ToString()).FirstOrDefault();
if (emoji != null)
content = content.Replace(item.Value, "<img style=‘width:22px‘ src=‘/content/emoji/" + Convert.ToInt32(emoji.codepoint, 16) + ".png‘ />");
}
return content;