TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How to design private messaging emoticons?

5 点作者 shergill将近 17 年前
I have a social networking site that I have coded myself. I have an option there for members to send comments back and forth to each other. I want to enable 'emoticons'; but I am not sure how to do that.. Do I just put some 'special tags' in the comment and then decode while displaying? can someone offer any input on this?

4 条评论

aupajo将近 17 年前
First off, I heavily advise against emoticons. People are usually perfectly happy with plain-text ones, and some people are avidly against graphical ones. Plus, if you have many triggers for emoticons that aren't immediately obvious, people can become confused when an icon pops up where they weren't expecting one.<p>That said, implementing said emoticons is a simple task. Assign a list of emoticon codes and image files (eg. ":)" =&#62; "smile.gif" and ":D" =&#62; "grin.gif") either hardcoded or in a database table depending on your needs, and use a simple search-and-replace function to replace the emoticon code with an image tag of the file. Make sure this is done when the message's body is parsed, and NOT before it gets inserted into the database.
评论 #238414 未加载
rslonik将近 17 年前
<a href="http://www.christian-seiler.de/projekte/php/bbcode/index_en.html" rel="nofollow">http://www.christian-seiler.de/projekte/php/bbcode/index_en....</a>
shaunxcode将近 17 年前
look into bbcode or the way msn, yahoo, aim, gmail chat etc. turn character combinations into "emoticons". Depending on your language of choice you will then do a string replace on the character combos for the image it relates to when you display that text.
shergill将近 17 年前
Thanks guys. I ended up doing a 'string replace' when displaying the msg content.