Home > Web Front-end > JS Tutorial > How to convert jquery.qqFace.js emoticons into WeChat character codes (detailed tutorial)

How to convert jquery.qqFace.js emoticons into WeChat character codes (detailed tutorial)

亚连
Release: 2018-06-22 18:21:20
Original
2292 people have browsed it

这篇文章主要介绍了将jquery.qqFace.js表情转换成微信的字符码的方法,以及jquery.qqface.js的使用方法,需要的朋友可以参考下

jquery.qqFace.js使用方法

引用

<script src="~/Content/qqFace/js/jquery.qqFace.js?v=3"></script>
<script src="~/Content/qqFace/js/jquery-browser.js"></script>
Copy after login

html

<p style="width:50px;height:30px;margin-top:3px;text-align:center;line-height:30px;border-right:1px solid #dee5e7"><img src="~/Content/emoji.png" class="emotion" /></p>
<textarea class="input" id="saytext" name="saytext" style="display:none"></textarea>
Copy after login

初始化

$(function () {
$(&#39;.emotion&#39;).qqFace({
id: &#39;facebox&#39;,
assign: &#39;saytext&#39;, //给输入框赋值
path: &#39;/Content/qqFace/arclist/&#39; //表情图片存放的路径
});
});
Copy after login

原来的jQuery.qqface.js有下面这个方法

function replace_em(str) {
str = str.replace(/\</g, &#39;<&#39;);
str = str.replace(/\>/g, &#39;>&#39;);
str = str.replace(/\n/g, &#39;<br/>&#39;);
str = str.replace(/\[em_([0-9]*)\]/g, &#39;<img src="/Content/qqFace/arclist/$1.gif" border="0" />&#39;);
return str;
}
Copy after login

点击表情会把表情转换成图片保存到$("#saytext")里,我自己修改一下将表情在我们需要显示地方显示出来

//修改原来js
var str = $("#saytext").val().trim();
$("#show").append(replace_em(str));
$("#saytext").val(&#39;&#39;);
Copy after login

将表情转换成微信字符码,因为做微信自动回复时回复文本消息不能回复文字加图片,所以我对照网上的数据,将表情图片一一对应的字符码找出来

我自己拼的字符码,按照上面表情的顺序组合的,有的没找到吗直接用微信的文字表示,微信发出去收到的也可以转换成表情

 private string emoij = "/::);/::~;/::B;/::|;/::<;/::$;/::X;/::Z;/::&#39;(;/::-|;/::@;/::P;/::D;/::O;/::(;/:–b;/::Q;/::T;/:,@P;/:,@-D;/::d;/:,@o;/::g;/:|-);/::!;/::L;/::>;/::,@;/:,@f;/::-S;/:?;/:,@x;/:,@@;/::8;/:,@!;/:xx;/:bye;/:wipe;/:dig;/:&-(;/:B-);/:<@;/:@>;/::-O;/:>-|;/:P-(;/::&#39;|;/:X-);/::*;/:@x;/:8*;[拥抱];[月亮];[太阳];[*];/:!!!;/:pd;/:pig;/:<W>;/:coffee;/:eat;/:heart;[强];[弱];[握手];[胜利];[抱拳];[勾引];[OK];[NO];/:rose;/:fade;/:showlove;[跳跳];[转圈]";
var emoijarray = emoij.Split(&#39;;&#39;);
int len = emoijarray.Length;
for (int i = 0; i < len; i++)
{
string str = string.Format("<img src={0}/Content/qqFace/arclist/{1}.gif{2} border={3}0{4}>",&#39;"&#39;,i+1, &#39;"&#39;, &#39;"&#39;, &#39;"&#39;);
if (xmlstr.Contains(str))//查找发送的文本消息中是否含有表情图片标签,有的话替换成对应的字符码,或许大家有更好的方式替换,我这只是循环去查找匹配的替换
{
xmlstr = xmlstr.Replace(str, emoijarray[i]);
}
}
Copy after login

这是微信上就可以收到表情了

上面是我整理给大家的,希望今后会对大家有帮助。

相关文章:

在vue中如何将页面公用的头部组件化(详细教程)

在JS中有关函数节流和函数防抖(详细教程)

使用three.js如何实现3D影院

在Vue中如何实现侧滑菜单组件

The above is the detailed content of How to convert jquery.qqFace.js emoticons into WeChat character codes (detailed tutorial). For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template