精华内容
下载资源
问答
  • emoji-mosaic是《纽约时代》的开发人员Eric Andrew Lewis做的一款照片转emoji软件,有时候我们在网上总会看到一些用emoji表情拼成的图片,这种图片要是手动去拼的话那是作死。这里给大家推荐的这款emoji-mosaic能...
  • emoji表情转换

    2018-09-05 12:26:34
    emoji表情转换为bbcode,bbcode替换为图片 教程链接https://blog.jam00.com/article/info/47.html
  • 分享几个常用的 属性字符串NSAtrributeString 和 NSString 普通字符串的 转换方法:     一:把普通的字符串,替换为包含图片的属性字符串 plist 文件,图片 格式见下图: ? 1 2 ...

    分享几个常用的 属性字符串NSAtrributeString 和 NSString 普通字符串的 转换方法:

     

     

    一:把普通的字符串,替换为包含图片的属性字符串

    plist 文件,图片 格式见下图:

    加载中...

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    +(NSMutableAttributedString *)stringToAttributeString:(NSString *)text
    {
        //先把普通的字符串text转化生成Attributed类型的字符串
        NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc]initWithString:text];
         
        NSString * zhengze = @\[[a-zA-Z0-9\u4e00-\u9fa5]+\]; //正则表达式 ,例如  [呵呵] 这种形式的通配符
         
        NSError * error;
    ?
    1
    <span style="font-family:"> NSRegularExpression * re = [NSRegularExpression regularExpressionWithPattern:zhengze options:NSRegularExpressionCaseInsensitive error:&error];//正则表达式</span>
    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
        if (!re)
        {
            NSLog(@%@,[error localizedDescription]);//打印错误
        }
         
        NSArray * arr = [re matchesInString:text options:0 range:NSMakeRange(0, text.length)];//遍历字符串,获得所有的匹配字符串
         
        NSBundle *bundle = [NSBundle mainBundle];
        NSString * path = [bundle pathForResource:@emotions ofType:@plist];  //plist文件,制作一个 数组,包含文字,表情图片名称
        NSArray * face = [[NSArray alloc]initWithContentsOfFile:path];  //获取 所有的数组
         
        //如果有多个表情图,必须从后往前替换,因为替换后Range就不准确了
        for (int j =(int) arr.count - 1; j >= 0; j--) {
            //NSTextCheckingResult里面包含range
            NSTextCheckingResult * result = arr[j];
             
            for (int i = 0; i < face.count; i++) {
                if ([[text substringWithRange:result.range] isEqualToString:face[i][@chs]])//从数组中的字典中取元素
                {
                    NSString * imageName = [NSString stringWithString:face[i][@png]];
                     
                    NSTextAttachment * textAttachment = [[NSTextAttachment alloc]init];//添加附件,图片
                     
                    textAttachment.image = [UIImage imageNamed:imageName];
                     
                    NSAttributedString * imageStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
                     
                    [attStr replaceCharactersInRange:result.range withAttributedString:imageStr];//替换未图片附件
                     
                    break;
                }
            }
        }
        return attStr;
    }

    二:获取属性字符串的size大小:

    注:对包含文字和图片的属性字符串,需要根据实际情况,调节其大小

     

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    +(CGSize)getAttributedTextSize:(NSString *)text
    {
        //先把普通的字符串text转化生成Attributed类型的字符串
        NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc]initWithString:text];
         
        NSString * zhengze = @\[[a-zA-Z0-9\u4e00-\u9fa5]+\];
         
        NSError * error;
         
        NSRegularExpression * re = [NSRegularExpression regularExpressionWithPattern:zhengze options:NSRegularExpressionCaseInsensitive error:&error];
        if (!re)
        {
            NSLog(@正则表达式匹配错误%@,[error localizedDescription]);
        }
         
        NSArray * arr = [re matchesInString:text options:0 range:NSMakeRange(0, text.length)];
         
         
        if (!arr.count)//说明字符串中没有表情通配符,是普通的文本,则计算文本size
        {
            NSDictionary *dic=@{NSFontAttributeName: [UIFont systemFontOfSize:14]};
             
             
            CGSize size1=[text boundingRectWithSize:CGSizeMake(160, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil].size;
             
            if (size1.height<=60)
            {
                size1.height=60;
            }
             
            else
            {
                size1.height+=15;
            }
             
             
             
            return size1;
        }
         
        NSBundle *bundle = [NSBundle mainBundle];
        NSString * path = [bundle pathForResource:@emotions ofType:@plist];
        NSArray * face = [[NSArray alloc]initWithContentsOfFile:path];
         
        //如果有多个表情图,必须从后往前替换,因为替换后Range就不准确了
        for (int j =(int) arr.count - 1; j >= 0; j--) {
            //NSTextCheckingResult里面包含range
            NSTextCheckingResult * result = arr[j];
             
            for (int i = 0; i < face.count; i++) {
                if ([[text substringWithRange:result.range] isEqualToString:face[i][@chs]])
                {
                    NSString * imageName = [NSString stringWithString:face[i][@png]];
                     
                    NSTextAttachment * textAttachment = [[NSTextAttachment alloc]init];
                     
                    textAttachment.image = [UIImage imageNamed:imageName];
                     
                    NSAttributedString * imageStr = [NSAttributedString attributedStringWithAttachment:textAttachment];
                     
                    [attStr replaceCharactersInRange:result.range withAttributedString:imageStr];
                     
                    break;
                }
            }
        }
         
        CGSize size2=[attStr boundingRectWithSize:CGSizeMake(180, 1000) options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;
         
        size2.height+=40//表情文字增加高度
         
         
         
        return size2;//返回属性字符串的尺寸
    }

    三: 属性字符串转为普通字符串, 关键点: 图片的二进制比对(可以放入到一个 子线程去做)

     

    图片二进制比对,获得图片名称:

     

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    //不能直接得到串的名字?
    -(NSString *)stringFromImage:(UIImage *)image
    {
        NSArray *face=[self getAllImagePaths];
         
        NSData * imageD = UIImagePNGRepresentation(image);
         
        NSString * imageName;
         
        for (int i=0; i<face.count; bundle="[NSBundle" data="UIImagePNGRepresentation(image);" emotions="" face="[[NSArray" getallimagepaths="" if="" image="[UIImage" imaged="" imagename="face[i][@chs];" nsarray="" nsbundle="" nsdata="" nsstring="" path="[bundle" pre="" return="" uiimage="">属性字符串转换为普通字符串:<p> </p><p>假设为TextView,label,button同理</p><p> </p><pre class="brush:java;">//把带有图片的属性字符串转成普通的字符串
    -(NSString *)textString
    {
        NSAttributedString * att = self.attributedText;
         
        NSMutableAttributedString * resutlAtt = [[NSMutableAttributedString alloc]initWithAttributedString:att];
         
         
        __weak __block UITextView * copy_self = self;
        //枚举出所有的附件字符串
        [att enumerateAttributesInRange:NSMakeRange(0, att.length) options:NSAttributedStringEnumerationReverse usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop) {
            //key-NSAttachment
            //NSTextAttachment value类型
            NSTextAttachment * textAtt = attrs[@NSAttachment];//从字典中取得那一个图片
            if (textAtt)
            {
                UIImage * image = textAtt.image;
                NSString * text = [copy_self stringFromImage:image];
                [resutlAtt replaceCharactersInRange:range withString:text];
                 
            }
             
             
        }];
         
         
        return resutlAtt.string;
     
    }
    </pre>
    <br>
    <p> </p>
    <p> </p>
    <p> </p>
    </face.count;>




    转载自:http://www.2cto.com/kf/201501/372511.html
    展开全文
  • emoji表情包转换插件

    2018-09-26 22:23:05
    emoji表情包图片转换插件,转换为网页正常显示!
  • ToEmoji.js 通过 emoji 配置文件,对html内容,进行图片替换文字的操作。 各有各的有点,font-face某些程度上,可能效率更高。 ToEmoji.js在小型场景下,可节省更多流量。 如有补充,可连续作者: BY:da宗熊 Email:
  • android平台下 视频转ascii码视频、图片转ascii码图片图片转低多边形风格图片图片emoji-masaic化 (未来功能,图片转彩色ascii码图片图片添加新海诚风格滤镜、图片人工智能风格迁移世界名画、人脸替换融合) ...
  • Emoji - 一个把Unicode字符和名称转换为表情符号图片的库
  • 表情符号马赛克 一个有趣的程序,将图片转换为表情符号马赛克。 谢谢
  • 可用于公众号接收用户表情消息,将表情码转换为对应的表情 html 内容 还可以获取聊天表情,可以应用于聊天应用的表情 install(安装) npm: npm install wechat-emoji-parser -S yarn: yarn add wechat-emoji-parser...
  • emoji 表情图片解决方法

    千次阅读 2017-03-27 11:35:13
    1:先弄到图片 上传到服务器上 2.下载 unicode 和 表情 映射关系xml  emoji4unicode.xml 在下面的rar 中 3.加入这个一个 转换类 package com.fanbaobao.util; import java.io.InputStream; import java....
    1:先弄到图片 上传到服务器上
    


    6955dcf3-3473-39fc-bcca-45e0cee03ed2.jpg

    2.下载 unicode 和 表情 映射关系xml
       emoji4unicode.xml  在下面的rar 中

    3.加入这个一个 转换类
    
    package com.fanbaobao.util;
    
    import java.io.InputStream;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    import javax.xml.namespace.QName;
    import javax.xml.stream.XMLEventReader;
    import javax.xml.stream.XMLInputFactory;
    import javax.xml.stream.XMLStreamException;
    import javax.xml.stream.events.Attribute;
    import javax.xml.stream.events.StartElement;
    import javax.xml.stream.events.XMLEvent;
    
    public class EmojiConverter {
    
    	private EmojiConverter() {
    	}
    
    	enum Type {
    		UNICODE, SOFTBANK
    	};
    
    	private Map<List<Integer>, String> convertMap;
    
    	public static class Builder {
    
    		private Type from;
    		private Type to;
    
    		public Builder from(Type type) {
    			this.from = type;
    			return this;
    		}
    
    		public Builder to(Type type) {
    			this.to = type;
    			return this;
    		}
    
    		public EmojiConverter build() {
    			EmojiConverter converter = new EmojiConverter();
    			readMap(converter);
    			return converter;
    		}
    
    		private static final String TRIM_PATTERN = "[^0-9A-F]*";
    
    		public void readMap(EmojiConverter converter) {
    			Map<List<Integer>, String> result = new HashMap<List<Integer>, String>();
    			converter.convertMap = result;
    
    			XMLEventReader reader = null;
    			try {
    
    				XMLInputFactory factory = XMLInputFactory.newInstance();
    
    				InputStream stream = EmojiConverter.class.getClassLoader()
    						.getResourceAsStream("emoji4unicode.xml");
    				reader = factory.createXMLEventReader(stream);
    
    				while (reader.hasNext()) {
    					XMLEvent event = reader.nextEvent();
    
    					if (event.isStartElement()) {
    						StartElement element = (StartElement) event;
    						if (element.getName().getLocalPart().equals("e")) {
    
    							Attribute fromAttr = element
    									.getAttributeByName(new QName(from.toString().toLowerCase()));
    							Attribute toAttr = element
    									.getAttributeByName(new QName(to.toString()
    											.toLowerCase()));
    							if (fromAttr == null) {
    								continue;
    							}
    							List<Integer> fromCodePoints = new ArrayList<Integer>();
    							String from = fromAttr.getValue();
    							if (from.length() > 6) {
    								String[] froms = from.split("\\+");
    								for (String part : froms) {
    									fromCodePoints.add(Integer.parseInt(
    											part.replaceAll(TRIM_PATTERN, ""),
    											16));
    								}
    							} else {
    								fromCodePoints.add(Integer.parseInt(
    										from.replaceAll(TRIM_PATTERN, ""), 16));
    							}
    							if (toAttr == null) {
    								result.put(fromCodePoints, null);
    							} else {
    								String to = toAttr.getValue();
    								StringBuilder toBuilder = new StringBuilder();
    								if (to.length() > 6) {
    									String[] tos = to.split("\\+");
    									for (String part : tos) {
    										toBuilder.append(Character
    												.toChars(Integer.parseInt(part
    														.replaceAll(
    																TRIM_PATTERN,
    																""), 16)));
    									}
    								} else {
    									toBuilder.append(Character.toChars(Integer
    											.parseInt(to.replaceAll(
    													TRIM_PATTERN, ""), 16)));
    								}
    								result.put(fromCodePoints, toBuilder.toString());
    							}
    
    						}
    					}
    				}
    
    				reader.close();
    			} catch (Exception e) {
    				e.printStackTrace();
    
    			} finally {
    				if (reader != null) {
    					try {
    						reader.close();
    					} catch (XMLStreamException e) {
    
    					}
    				}
    
    			}
    
    		}
    
    	}
    
    	public String convert(int width,int height,String imgpath,String input) {
    		StringBuilder result = new StringBuilder();
    		int[]codePoints = toCodePointArray(input);
    		for(int i = 0; i < codePoints.length; i++){
    			List<Integer> key2 = null;
    			if(i + 1 < codePoints.length){
    				key2 = new ArrayList<Integer>();
    				key2.add(codePoints[i]);
    				key2.add(codePoints[i + 1]);
    				
    				if(convertMap.containsKey(key2) || 65039==codePoints[i + 1]){  //处理 iphone5 xxxx-fe0f.png
    					String aa=Integer.toHexString(codePoints[i])+"-"+Integer.toHexString(codePoints[i+1]);
    					String value = convertMap.get(key2);
    					if(value != null || 65039==codePoints[i + 1]){
    						result.append("<img width=\""+width+"px\" height=\""+height+"px\" style=\"vertical-align: bottom;\" src=\""+imgpath+"");
    						result.append(aa);
    						result.append(".png\"/>");
    					}
    					i++;
    					continue;
    				}
    			}
    			
    			List<Integer> key1 = new ArrayList<Integer>();
    			key1.add(codePoints[i]);
    			if(convertMap.containsKey(key1)){
    				String aa=Integer.toHexString(codePoints[i]);
    				String value = convertMap.get(key1);
    				if(value != null){
    					result.append("<img width=\""+width+"px\" height=\""+height+"px\" style=\"vertical-align: bottom;\" src=\""+imgpath+"");
    					result.append(aa);
    					result.append(".png\"/>");
    					//System.out.println("key:"+key1);
    					//System.out.println("Map:"+value);
    				}
    				continue;
    			}
    			if(128529==codePoints[i]){  //处理空格
    				result.append(" ");
    				continue;
    			}
    			result.append(Character.toChars(codePoints[i]));
    			
    		}
    		return result.toString();
    	}
     
    	int[] toCodePointArray(String str) {
    		char[] ach = str.toCharArray();
    		int len = ach.length;
    		int[] acp = new int[Character.codePointCount(ach, 0, len)];
    		int j = 0;
    
    		for (int i = 0, cp; i < len; i += Character.charCount(cp)) {
    			cp = Character.codePointAt(ach, i);
    			acp[j++] = cp;
    		}
    		return acp;
    	}
    
    }
    


    3.调用 servlet
    
    public class ShareServlet extends HttpServlet {
    	
    	private static EmojiConverter converter;
    	private static String imgpath="http://xx.xxxx.com/opt/siteimg/mika/emoji/unicode/";
    	@Override
    	public void init() throws ServletException {
    		converter = new EmojiConverter.Builder()
    		.from(Type.UNICODE)
    		.to(Type.SOFTBANK)
    		.build();
    	}
    
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    			throws ServletException, IOException {
    		
    		FbbServiceClient service=null;
    		try {
    			String userid=request.getParameter("userid");
    			String bid=request.getParameter("bid");
    			if(userid!=null && bid!=null && userid.length()>0 && bid.length()>0){
    				service=new FbbServiceClient();
    				SnapService.Client client=service.open();
    				SnapItem item=client.getItemByIdS(Long.valueOf(userid),Long.valueOf(bid));
    				//进行转换
    				if(item.getUserName()!=null && item.getUserName().length()>0)
    					item.setUserName(converter.convert(20,20,imgpath,item.getUserName()));
    				if(item.getItemName()!=null && item.getItemName().length()>0)
    					item.setItemName(converter.convert(20,20,imgpath,item.getItemName()));
    				request.setAttribute("SnapItem", item);
    				request.getRequestDispatcher("/wxshare.jsp").forward(request, response);
    			}
    		} catch (Exception e) {
    			e.printStackTrace();
    			logger.error("errorcode ::: " + e.getMessage(), e);
    		}finally{
    			if(service!=null)
    				service.close();
    		}
    	}
    
    }
    


    4.写成一个ELfunction 在jsp EL 表达式中 使用
    
    package com.fanbaobao.util;
    
    import com.fanbaobao.util.EmojiConverter.Type;
    
    public class EmojiFunction {
    	private static EmojiConverter converter;
    	private static String imgpath="http://xx.xxxx.com/opt/siteimg/mika/emoji/unicode/";
    	static{
    		converter = new EmojiConverter.Builder()
    		.from(Type.UNICODE)
    		.to(Type.SOFTBANK)
    		.build();
    	}
    
    	public static String emoji(String arg){
    		return emojiFun(null,null,arg);
    	}
    	
    	public static String emojiFun(Integer width,Integer height,String arg){
    		if(width==null){
    			width=20;
    		}
    		if(height==null){
    			height=20;
    		}
    		return converter.convert(width.intValue(),height.intValue(),imgpath,arg);
    	}
    }
    


    5;编写 tld文件
    <?xml version="1.0" encoding="UTF-8"?>
    <taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd">
    	<tlib-version>1.0</tlib-version>
    	<short-name>mk</short-name>
    	<uri>/mikadata-tags</uri>
    	
    	<function>  
            <name>emoji</name>
            <function-class>com.fanbaobao.util.EmojiFunction</function-class>  
            <function-signature> 
                java.lang.String emoji(java.lang.String)
            </function-signature>  
        </function>
    	
    	<function>  
            <name>emojiFun</name>
            <function-class>com.fanbaobao.util.EmojiFunction</function-class>  
            <function-signature> 
                java.lang.String emojiFun(java.lang.Integer,java.lang.Integer,java.lang.String)
            </function-signature>  
        </function>
    </taglib>
    


    6:jsp中使用
    
    <%@ taglib uri="/mikadata-tags" prefix="mk"%>
    
    <td>${mk:emoji(dataObject.comment)}</td>
    
    • 6955dcf3-3473-39fc-bcca-45e0cee03ed2-thumb.jpg
    • 大小: 214 KB
    展开全文
  • 那么这样,一个表情带一个表情描述的好处就是,当我们发送信息时,数据存入数据库后不会直接存储Emoji表情图片,而是直接存储表情描述这个字符串。但是android 系统自带的Emoji表情描述是什么呢?似乎不知道,网上查...

    前言

    Emoji表情几乎都是有表情描述的,如愤怒的表情会有[愤怒],这样的描述,这里就是举了个列子,至于是什么样的表现形势,这是可以自己定义的。那么这样,一个表情带一个表情描述的好处就是,当我们发送信息时,数据存入数据库后不会直接存储Emoji表情图片,而是直接存储表情描述这个字符串。

    但是android 系统自带的Emoji表情描述是什么呢?似乎不知道,网上查了很多资料,说emoji有个自己的规则什么的。呃。。。表示看了半天没看懂。。。,于是乎就研究,系统自带的emoji如果打印成字符串是个什么鬼呢?
    正文

    于是乎我们进行了打印,打印之后效果图如下:
    
    public class EmojiActivity extends Activity {
        private TextView tv;
        private EditText et;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_emoji);
            initView();
            viewOper();
        }
    
        private void initView() {
            tv = findView(R.id.tv);
            et = findView(R.id.et);
        }
    
        private void viewOper() {
            tv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    System.out.println(et.getText().toString());
                }
            });
        }
    
        private <T> T findView(int id) {
            return (T) findViewById(id);
        }
    }

    这里写图片描述
    打印的结果:
    这里写图片描述

    一个不知道是什么的字符,这样存入数据库只会是一串问号,一朋友的是直接存不进去。查资料说要升级数据库,我勒个去,这样我肯定是不会去干的,因为不会后台呀。因此我就想到了把这个字符串拆分为字符对应的字符试试。

    于是乎,就写了这样一段代码。

    
        /**
         * 将系统表情转化为字符串
         *
         * @param s
         * @return
         */
        public static String getString(String s) {
            int length = s.length();
            String context = "";
            //循环遍历字符串,将字符串拆分为一个一个字符
            for (int i = 0; i < length; i++) {
                char codePoint = s.charAt(i);
                //判断字符是否是emoji表情的字符
                if (isEmojiCharacter(codePoint)) {
                    //如果是将以大括号括起来
                    String emoji = "{" + Integer.toHexString(codePoint) + "}";
                    context = context + emoji;
                    continue;
                }
                context = context + codePoint;
            }
            return context;
        }
    
        /**
         * 是否包含表情
         *
         * @param codePoint
         * @return 如果不包含 返回false,包含 则返回true
         */
    
        private static boolean isEmojiCharacter(char codePoint) {
            return !((codePoint == 0x0) || (codePoint == 0x9) || (codePoint == 0xA)
                    || (codePoint == 0xD)
                    || ((codePoint >= 0x20) && (codePoint <= 0xD7FF))
                    || ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) || ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF)));
        }

    说下这段代码的流程吧,显示设置进去一个字符串,然后遍历循环判断每个字符是否为emoji表情。emoji表情的字符比普通字符大一些。别看上图输出的是一个‘口’字,但是他占用了两个字符。因此判断完后转化为数字并以转化为16进制的字符串。并以大括号来分隔开来。

    那么转化后的样子就是这样的。
    这里写图片描述

    可以看出没转换后的‘口’字符是两个字符。这样我们就转化成功了,可以直接存入数据库了。那么我们如果要从数据库读取出来然后进行显示emoji表情呢。这个就简单了,直接进行正则匹配后截取中间的16进制转化为字符然后拼接为字符串就是了。

    代码如下:

    
        /**
         * 将表情描述转换成表情
         *
         * @param str
         * @return
         */
        public static String getEmoji(Context context, String str) {
            String string = str;
            String rep = "\\{(.*?)\\}";
            Pattern p = Pattern.compile(rep);
            Matcher m = p.matcher(string);
            while (m.find()) {
                String s1 = m.group().toString();
                String s2 = s1.substring(1, s1.length() - 1);
                String s3;
                try {
                    s3 = String.valueOf((char) Integer.parseInt(s2, 16));
                    string = string.replace(s1, s3);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return string;
        }

    将emoji表情描述转化过来后的结果如下图:

    这里写图片描述

    然后将转化的结果设置展示组件就可以了,这样我们系统自带emoji表情与表情描述就这样转换完了。

    展开全文
  • emoji-demo

    2019-02-16 16:26:48
    包含了大量的emoji的表情图片和使用代码,使用到了jquery-2.1.4.min,需要转换数据库编码
  • 例如把 😊...如果把emoji换成图片的话 还得存到服务器里,所以想知道能不能直接转成base64 <link rel="shortcut icon" type="image/x-icon" href=“”></p>
  • 最近项目需要做QQ微信表情代码的图片展示。先收集一些网站做资料使用方法,及其源码如下html>varoQQFace=newQQFace("images/faceIcon/");varsString="[微笑]/pz/::)";vars=oQQFace.replace(sString);document....

    最近项目需要做QQ微信表情代码的图片展示。

    先收集一些网站做资料

    使用方法,及其源码如下html>

    var oQQFace = new QQFace("images/faceIcon/");

    var sString = "[微笑] /pz /::)";

    var s = oQQFace.replace(sString);

    document.getElementById("test").innerHTML = s;

    /*!

    * qqface v1.0.0

    * http://www.linchaoqun.com

    * Date: 2016-08-23

    * ie.:

    var oQQFace = new QQFace();

    var sString = "[微笑]  /::) /墨镜";

    var s = oQQFace.replace(sString);

    */

    "use strict";

    ;(function(){

    var root = this;

    var qqFace = function(path){

    this.path = path || "images/faceIcon/";

    this.init();

    };

    /** @private */

    qqFace.prototype.init = function(){

    var self = this;

    self.map = [];

    var a = [],b = [];

    if(!this.data){

    console.error("请导入qqfaceConfig.js");

    return;

    }

    for (var i in this.data) {

    var item0 = this.data[i][0],item1 = this.data[i][1],item2 = this.data[i][2];

    self.map[item0] = i;

    self.map[item1] = i;

    a.push(self.escape_rx(item0));

    b.push(item1);

    if(item2){

    b.push(item2);

    self.map[item2] = i;

    }

    }

    self.rx_en =  new RegExp('(' + a.join('|') + ')', 'g');// ie. /::)

    self.rx_CN = new RegExp(('\\/(' + b.join('|') + ')'), 'g');// ie. /微笑 /wx

    self.rx_CN_bracket = new RegExp(('\\[(' + b.join('|') + ')\\]'), 'g');// ie. [微笑]

    };

    /** @private */

    qqFace.prototype.escape_rx = function(text){

    return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");

    };

    /**

    * @param{String} s 要转换的字符串s

    * @return 转换为带表情的字符串

    **/

    qqFace.prototype.replace = function(s){

    var self = this;

    var aRex = [self.rx_en, self.rx_CN, self.rx_CN_bracket];

    for(var i in aRex){

    s = s.replace(aRex[i],function(){

    return self.html(self.map[arguments[1]]);

    });

    }

    return s;

    };

    /** @private */

    qqFace.prototype.html = function(id){

        return "";

    };

    // export

    if (typeof define === 'function' && define.amd){

    define(function() { return qqFace; })

    }else{

    root.QQFace = qqFace;

    }

    }).call(function(){

    return this || (typeof window !== 'undefined' ? window : global);

    }());/*!

    * qqface v1.0.0

    * http://www.linchaoqun.com

    *

    * Copyright 2016, linchaoqun

    * Date: 2016-08-23

    * ie.:

    var oQQFace = new QQFace();

    var sString = "[微笑]  /::) /墨镜";

    var s = oQQFace.replace(sString);

    */

    "use strict";

    (function(){

    var fnData = function(QQFace){

    /** @private */

    QQFace.prototype.data = {

    "0":["/::)","微笑","wx"],

    "1":["/::~","撇嘴","pz"],

    "2":["/::B","色","se"],

    "3":["/::|","发呆","fd"],

    "4":["/:8-)","得意","dy"],

    "5":["/::

    "6":["/::$","害羞","hx"],

    "7":["/::X","闭嘴","bz"],

    "8":["/::Z","睡","shui"],

    "9":["/::’(","大哭","dk"],

    "10":["/::-|","尴尬","gg"],

    "11":["/::@","发怒","fn"],

    "12":["/::P","调皮","tp"],

    "13":["/::D","呲牙","cy"],

    "14":["/::O","惊讶","jy"],

    "15":["/::(","难过","ng"],

    "16":["/::+","酷","kuk"],

    "17":["/:–b","冷汗","lengh"],

    "18":["/::Q","抓狂","zk"],

    "19":["/::T","吐","tuu"],

    "20":["/:,@P","偷笑","tx"],

    "21":["/:,@-D","可爱","ka"],

    "22":["/::d","白眼","baiy"],

    "23":["/:,@o","傲慢","am"],

    "24":["/::g","饥饿","jie"],

    "25":["/:|-)","困","kun"],

    "26":["/::!","惊恐","jk"],

    "27":["/::L","流汗","lh"],

    "28":["/::>","憨笑","hanx"],

    "29":["/::,@","大兵","db"],

    "30":["/:,@f","奋斗","fendou"],

    "31":["/::-S","咒骂","zhm"],

    "32":["/:?","疑问","yiw"],

    "33":["/:,@x","嘘...","xu"],

    "34":["/:,@@","晕","yun"],

    "35":["/::8","折磨","zhem"],

    "36":["/:,@!","哀","shuai"],

    "37":["/:!!!","骷髅","kl"],

    "38":["/:xx","敲打","qd"],

    "39":["/:bye","再见","zj"],

    "40":["/:wipe","擦汗","ch"],

    "41":["/:dig","抠鼻","kb"],

    "42":["/:handclap","鼓掌","gz"],

    "43":["/:&-(","糗大了","qd"],

    "44":["/:B-)","坏笑","huaix"],

    "45":["/:

    "46":["/:@>","右哼哼","yhh"],

    "47":["/::-O","哈欠","hq"],

    "48":["/:>-|","鄙视","bs"],

    "49":["/:P-(","委屈","wq"],

    "50":["/::’|","快哭了","kk"],

    "51":["/:X-)","阴险","yx"],

    "52":["/::*","亲亲","qq"],

    "53":["/:@x","吓","xia"],

    "54":["/:8*","可怜","kel"],

    "55":["/:pd","菜刀","cd"],

    "56":["/:","西瓜","xig"],

    "57":["/:beer","啤酒","pj"],

    "58":["/:basketb","篮球","lq"],

    "59":["/:oo","乒乓","pp"],

    "60":["/:coffee","咖啡","kf"],

    "61":["/:eat","饭","fan"],

    "62":["/:pig","猪头","zt"],

    "63":["/:rose","玫瑰","mg"],

    "64":["/:fade","凋谢","dx"],

    "65":["/:showlove","示爱","sa"],

    "66":["/:heart","爱心","xin"],

    "67":["/:break","心碎","xs"],

    "68":["/:cake","蛋糕","dg"],

    "69":["/:li","闪电","shd"],

    "70":["/:bome","炸弹","zhd"],

    "71":["/:kn","刀","dao"],

    "72":["/:footb","足球","zq"],

    "73":["/:ladybug","瓢虫","pch"],

    "74":["/:shit","便便","bb"],

    "75":["/:moon","月亮","yl"],

    "76":["/:sun","太阳","ty"],

    "77":["/:gift","礼物","lw"],

    "78":["/:hug","拥抱","yb"],

    "79":["/:strong","强","qiang"],

    "80":["/:weak","弱","ruo"],

    "81":["/:share","握手","ws"],

    "82":["/:v","胜利","shl"],

    "83":["/:@)","抱拳","bq"],

    "84":["/:jj","勾引","gy"],

    "85":["/:@@","拳头","qt"],

    "86":["/:bad","差劲","cj"],

    "87":["/:lvu","爱你","aini"],

    "88":["/:no","bu","no"],

    "89":["/:ok","hd","ok"],

    "90":["/:love","爱情","aiq"],

    "91":["/:","飞吻","fw"],

    "92":["/:jump","跳跳","tiao"],

    "93":["/:shake","发抖","fad"],

    "94":["/:","怄火","oh"],

    "95":["/:circle","转圈","zhq"],

    "96":["/:kotow","磕头","kt"],

    "97":["/:turn","回头","ht"],

    "98":["/:skip","跳绳","tsh"],

    "99":["/:","挥手","hsh"],

    "100":["/:#-0","激动","jd"],

    "101":["/:","街舞","jw"],

    "102":["/:kiss","献吻","xw"],

    "103":["/:

    "104":["/:&>","右太极","youtj"]

    };

    }

    if (typeof define === 'function' && define.amd){

    define(["qqface"],function(QQFace) {

    fnData(QQFace);

    })

    }else{

    fnData(QQFace);

    }

    })();

    展开全文
  • emojify.js 是一个 JavaScript 模块用来转换 emoji 关键字到图片。目前 Gitter 正在使用该模块。emoji 关键字的描述请看 emoji-cheat-sheet.com.示例代码:emojify.setConfig({  emojify_tag_type : 'div', //...
  • 使用此库,您可以轻松地使用自己的CDN提供程序来托管表情符号图片和PNG文件,并自定义表情符号渲染。 您还可以在使用精灵和奇异的PNG图标之间进行切换,以获取最轻松的体验。 这是我在其他React EmojiOne库中尚未...
  • java web emoji表情显示

    千次阅读 2015-12-18 09:35:13
    关于emoji表情显示 之前公司没想要做一个pc端程序,所以没有把表情定好规则,数据库中存储的是utf8mb4字符集 这个时候表情是需要转换的 在网上收到一篇文章 比较简单 不过后来还是实现了我想要的效果废话不多说了看...
  • Android 利用正则+反射+SpannableString展示Emoji表情 简单实现一下,仅供参考,先给一张图片~~ 先说下实现的步骤 1.从输入的字符串中获取匹配emoji表情名称的...4.emoji Drawable转换成ImageSpan 5.将原字符串转
  • CSS雪碧图制作emoji表情包

    千次阅读 2018-03-02 14:23:27
    原理:利用雪碧图,来实现emoji表情包,减少图片请求数。 表情包转换为文字 &amp; 文字转换为表情包 维护两个对象来实现。 缺点:表情包大小由雪碧图中表情包大小控制,不能更改。 htm代码 &lt;!doctype...
  • 我想在MAC下面用pillow把一些文本转换成PNG图片,在转普通文字的时候都没问题,但在遇到emoji字符的时候就搞不定了,代码如下: import loggingimport PIL.Image import PIL.ImageDraw import PIL.ImageFont ...
  • 一个聊天界面,包括从网络下载大表情并发,图片发送,文字发送,Emoji表情发送,自定义表情键盘,Emoji表情键盘,仿QQ功能键盘等等…… 8月1日更新:每个表情符号表情页的最后添加删除图标。 8月5日更新:支持聊天...
  • 转载,原文链接: ... ...Emoji 绘文字是日本在通讯上被广泛使用的一种交互式情境图片... Emoji 绘文字都有一个属于自己的 unicode 编码,当字符遇到这类的编码时,就会自动转换成对应的 Emoji 绘文字,其实不只是 Emoj
  • 升级 MySql 支持 emoji 表情 与 utf8mb4

    千次阅读 2016-03-18 17:24:14
    Emoji 表情是字符不是图片,如果客户端、数据库不支持就升级一下,浏览器也是。 既然是字符,那可不可人工处理替换掉?可以是可以但是不建議。其实升级下相关组件就可以了。 Emoji 表情不是苹果独家的,他属于 ...
  • EWS 中有一部分代码负责将这些文字转写转换为相应或相似的 Emoji 字符。 但由于微信方面的更新,这些表情符号的转写在一直更新,所以在这里征集一些在使用中遇到的没有被 EWS 转换Emoji 的表情符号。...
  • DJEmotionTextView 转换方法 - (NSMutableString *)fullText { NSMutableString *text = [[NSMutableString alloc] init]; // 遍历当前attributedText,此API会自动分割attributedText中存在的文本,Emoji,...

空空如也

空空如也

1 2 3
收藏数 52
精华内容 20
关键字:

图片转换emoji