关于emoji表情
/**
/* 表情编码
/* @param emoji:表情符号
**/
encodeEmoji: function (content) {
var imgHtml = "";
var emojisReg = ["\\#:z", "\\#-\\.-", "\\#:D", "\\#:\\)", "\\#:\\]", "\\#;-L", "\\#;-D", "\\#:<", "\\#\\*_\\*", "\\#\\+_\\+", "\\#>_<", "\\#\\^_\\+", "\\#;P", "\\#0o0", "\\#:-D", "\\#ToT", "\\#>P", "\\#z_z", "\\#-_,-", "\\#\\^_\\^", "\\#>o<", "\\#;<", "\\#@_@", "\\#\\+o\\+", "\\#;z\\*", "\\#x_x", "\\#\\.-b", "\\#@,@", "\\#>-<", "\\#:-<", "\\#\\(cute\\)", "\\#\\(bh\\)", "\\#\\(b\\)", "\\#\\(g\\)", "\\#-@", "\\#\\(p\\)", "\\#\\(18\\)", "\\#\\(kiss\\)", "\\#\\(flag\\)", "\\#\\(d\\)", "\\#\\(pig\\)", "\\#\\(bg\\)", "\\#\\(qiu\\)", "\\#\\(dance\\)", "\\#\\(good\\)", "\\#\\(bingo\\)", "\\#\\(ok\\)", "\\#\\(strong\\)", "\\#\\(b3g\\)", "\\#\\(blg\\)", "\\#\\(yoga\\)", "\\#\\(cut\\)", "\\#\\(head\\)", "\\#\\(no\\)", "\\#\\(\\^L\\)", "\\#\\(love\\)"];
var emojisReg1 = ["\\#:z", "\\#-\\.-", "\\#:D", "\\#:\\)", "\\#:\\]", "\\#;-L", "\\#;-D", "\\#:<", "\\#\\*_\\*", "\\#\\+_\\+", "\\#>_<", "\\#\\^_\\+", "\\#;P", "\\#0o0", "\\#:-D", "\\#ToT", "\\#>P", "\\#z_z", "\\#-_,-", "\\#\\^_\\^", "\\#>o<", "\\#;<", "\\#@_@", "\\#\\+o\\+", "\\#;z\\*", "\\#x_x", "\\#\\.-b", "\\#@,@", "\\#>-<", "\\#:-<", "\\#\\(cute\\)", "\\#\\(bh\\)", "\\#\\(b\\)", "\\#\\(g\\)", "\\#-@", "\\#\\(p\\)", "\\#\\(18\\)", "\\#\\(kiss\\)", "\\#\\(flag\\)", "\\#\\(d\\)", "\\#\\(pig\\)", "\\#\\(bg\\)", "\\#\\(qiu\\)", "\\#\\(dance\\)", "\\#\\(good\\)", "\\#\\(bingo\\)", "\\#\\(ok\\)", "\\#\\(strong\\)", "\\#\\(b3g\\)", "\\#\\(blg\\)", "\\#\\(yoga\\)", "\\#\\(cut\\)", "\\#\\(head\\)", "\\#\\(no\\)", "\\#\\(\\^L\\)", "\\#\\(love\\)"];
for (var i = 0; i < emojisReg.length; i++) {
imgHtml = "<img src=\"./imgs/smiley_" + i + ".png\">";
var reg = new RegExp(emojisReg[i], "gm");
content = content.replace(reg, imgHtml);
}
for (var i = 0; i < emojisReg1.length; i++) {
imgHtml = "<img src=\"./imgs/smiley_" + i + ".png\">";
var reg = new RegExp(emojisReg1[i], "gm");
content = content.replace(reg, imgHtml);
}
return content;
}, /**
* 表情解码
* @param content
* @returns {*}
*/
decodeEmoji: function (content) {
var imgHtml = "";
var emojisTag = ["#:z", "#-.-", "#:D", "#:)", "#:]", "#;-L", "#;-D", "#:<",
"#*_*", "#+_+", "#>_<", "#^_+", "#;P", "#0o0", "#:-D", "#ToT", "#>P", "#z_z",
"#-_,-", "#^_^", "#>o<", "#;<", "#@_@", "#+o+", "#;z*", "#x_x", "#.-b", "#@,@",
"#>-<", "#:-<", "#(cute)", "#(bh)", "#(b)", "#(g)", "#-@", "#(p)", "#(18)",
"#(kiss)", "#(flag)", "#(d)", "#(pig)", "#(bg)", "#(qiu)", "#(dance)", "#(good)",
"#(bingo)", "#(ok)", "#(strong)", "#(b3g)", "#(blg)", "#(yoga)", "#(cut)", "#(head)",
"#(no)", "#(^L)", "#(love)"];
for (var i = 0; i < emojisTag.length; i++) {
imgHtml = "<img src=\"./imgs/smiley_" + i + ".png\">";
var reg = new RegExp(imgHtml, "gm");
content = content.replace(reg, emojisTag[i]);
}
return content;
},
关于emoji表情的更多相关文章
- 移动前端手机输入法自带emoji表情字符处理
今天,测试给我提了一个BUG,说移动端输入emoji表情无法提交.很早以前就有思考过,手机输入法里自带的emoji表情,应该是某些特殊字符.既然是字符,那应该都能提交才对,可是为啥会被卡住呢?搜了一下 ...
- JS操作Unicode编码的emoji表情显示在页面
前言:项目中用到了emoji表情,后端传递数据时直接是以Unicode形式,在页面总是无法展示,找尽各种方法总算是试出了一种,虽然达到效果但是并不是特别理解其中的原理并且无比笨拙,贴在这用作笔记,如果 ...
- IOS Emoji表情
IOS Emoji 前言:我比较喜欢有趣的东西,有一些有趣的小东西,可能不是多么多么牛逼,也可能不需要多高深的技巧,也不会为其他什么强大的功能而服务,但是有时候将很多有趣的小东西组合起来运用,比如在你 ...
- 有关emoji表情以及utf-16编码
昨日IOS组的同事遇到一个棘手的问题:当输入框内含有emoji表情时,如何获取文本框内的字符数(一个emoji表情算一个字符). 先从我最近接触的JAVA说起,JAVA中,在使用S ...
- iOS emoji表情转码 或者判断
如果项目中有评论或者信息恢复的地方,往往会用到emoji,有时候如后台不支持emoji,就会显示乱码错误,我们可以把emoji转成unicode编码或者utf8编码格式传给服务器.当然如果后台服务器接 ...
- mysql支持IOS的Emoji表情
原因: UTF-8编码有可能是两个.三个.四个字节.Emoji表情是4个字节,而Mysql的utf8编码最多3个字节,所以数据插不进去. 解决办法: 将Mysql的编码从utf8转换成utf8mb4 ...
- iOS 获取emoji表情和拦截emoji表情
1 2 //将数字转为 #define EMOJI_CODE_TO_SYMBOL(x) ((((0x808080F0 | (x & 0x3F000) >> 4) | (x &a ...
- 让mysql支持emoji表情
一.问题及原因 APP产品想对Emoji进行支持,但发现mysql数据库无法写入表情.原因是我们的mysql数据库默认用的是utf8编码,utf8编码存储时用的是三个字节,但Emoji表情是4个字节, ...
- emoji表情初探
2015年12月28日 14:24:51 星期一 首先注意的地方: 1. emoji是需要操作系统支持的, 例如: ios更新时, 会在升级日志里说明, 增加了对多少个emoji图标的支持. 原理上是 ...
- 数据库支持emoji表情
从MySQL5.5.3开始,MySQL 支持一种utf8mb4的字符集,这个字符集能够支持4字节的UTF8编码的字符.utf8mb4字符集能够完美地兼容utf8字符串.在数据存储方面,当一个普通中文字 ...
随机推荐
- Inside NGINX: How We Designed for Performance & Scale
NGINX leads the pack in web performance, and it’s all due to the way the software is designed. Where ...
- Xshell连接Ubuntu失败问题
转自:https://www.linuxidc.com/Linux/2017-08/146222.htm Xshell是一个安全终端模拟软件,可以进行远程登录.我使用XShell的主要目的是在Wind ...
- sqlite元数据
sqlite数据库每个文件都是一个database,因此同一个文件内部不再划分database.sqlite没有提供像mysql那样的show tables;和desc 表名类似的语句.许多数据库的元 ...
- Linux修改终端提示符
打开~/.bashrc可以看到命令提示的内容为:\u@\h\w\$ \u表示用户名,\h表示主机名,\w表示当前目录,\$表示命令提示符(普通用户$,超级用户#) 这个命令提示符有点长,很碍事,\u@ ...
- Alias Method for Sampling 采样方法
[Alias Method for Sampling]原理 对于处理离散分布的随机变量的取样问题,Alias Method for Sampling 是一种很高效的方式. 在初始好之后,每次取样的复杂 ...
- 【DeepLearning】Exercise:Self-Taught Learning
Exercise:Self-Taught Learning 习题链接:Exercise:Self-Taught Learning feedForwardAutoencoder.m function [ ...
- YAML 语言教程(转载)
用YAML语言读取配置是最快的,之前的suricata中用yaml读取了配置,并且在代码运行期间,对配置进行了维护,所以抽点时间,来了解一下YAML语言编程,下文虽然对YAML语言和JAVAScrip ...
- 【SQL】SQL 中Select语句完整的执行顺序
SQL Select语句完整的执行顺序: 1.from子句组装来自不同数据源的数据: 2.where子句基于指定的条件对记录行进行筛选: 3.group by子句将数据划分为多个分组: 4.使用聚集函 ...
- 【java】详解集合
目录结构: contents structure [-] 集合概述 什么是集合 Collection和Map的区别 List和Set的区别 ArrayList和LinkedList的区别 HashSe ...
- request.getRequestURI() 、request.getRequestURL() 、request.getContextPath()、request.getServletPath()区别
request.getRequestURI() /jqueryWeb/resources/request.jsprequest.getRequestURL() http://localhost:808 ...