如何在聊天应用程序中添加表情符号 [英] how to add emoticons in our chat application

查看:113
本文介绍了如何在聊天应用程序中添加表情符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能否帮助我在我们的asp.net聊天应用程序中添加表情符号。



请在c#中为我的asp.net网站添加表情符号的代码。













问候

sonam vij

Can you help me regarding adding emoticons to our asp.net chat application.

please provide me the code for adding smileys to my asp.net website in c#.






Regards
sonam vij

推荐答案

你需要写一些类型的文本解析器!



这是一个简短的例子:



You need to write some type of text parser!

Here is a brief example:

public class EmoticonRender()
{

  private List<keyvaluepair<string,string>> _dictionary = new List<keyvaluepair<string,string>>() 
  {
    new KeyValuePair<string,>(":-)", "smile.png"),
    new KeyValuePair<string,>(";-(", "cry.png")
  }

  public string Parse(string text)
  {
    foreach(KeyValuePair<string,> kvp in _dictionary)
    {
      text = text.Replace(kvp.Key, "<img src="\""" kvp.value="" />");
    }
    return text;
  }

}





该类查看表情符号的文本表示并替换它们使用渲染图像所需的HTML。



使用很简单:





The class looks the the text representation of the emoticons and replaces them with the HTML required to render the images.

Usage is simple:

string text = "hello :-) don't be sad ;-(";
EmoticonRender parser = new EmoticonRender();
string parsedText = parser.Parse(text); 


尝试

http://pravin.insanitybegins.com/posts/cs-emoticons [ ^ ]

在ASP.NET网页上显示表情符号 [ ^ ]


你好sonam,对于你的解决方案,你可以通过链接http://stackoverflow.com/questions/13528276/how-to-add-smiley-feature-in-chat-application-in-java和现场演示(使用jquery for smiley)使用链接http://jsfiddle.net/Etmrs/.....
hello sonam, for your solution you could go-through the link "http://stackoverflow.com/questions/13528276/how-to-add-smiley-feature-in-chat-application-in-java" and for live demo (which using jquery for smiley) use link "http://jsfiddle.net/Etmrs/".....


这篇关于如何在聊天应用程序中添加表情符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆