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;
}
}
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);