当前位置: 首页>>代码示例>>Java>>正文


Java EmojiParser.parseToUnicode方法代码示例

本文整理汇总了Java中com.vdurmont.emoji.EmojiParser.parseToUnicode方法的典型用法代码示例。如果您正苦于以下问题:Java EmojiParser.parseToUnicode方法的具体用法?Java EmojiParser.parseToUnicode怎么用?Java EmojiParser.parseToUnicode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vdurmont.emoji.EmojiParser的用法示例。


在下文中一共展示了EmojiParser.parseToUnicode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: newUser

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
private void newUser(GuildMessageReceivedEvent event) {
	Connection connect = Connections.getConnection();
	
	try {
		String name = event.getAuthorName();
		if (name != null)
			name = EmojiParser.parseToUnicode(name);
		String nick = event.getAuthorNick();
		if (nick != null)
			nick = EmojiParser.parseToUnicode(nick);

		PreparedStatement ps = connect.prepareStatement("INSERT INTO users (userid, username, nickname) VALUES (?, ?, ?)");
		ps.setString(1, event.getAuthor().getId());
		ps.setString(2, name);
		ps.setString(3, nick);
		ps.executeUpdate();
	
	} catch (SQLException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Bermos,项目名称:kokbot,代码行数:22,代码来源:Karma.java

示例2: emojiParse

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public static String emojiParse(String text) {
    Matcher       m         = matcher("<span class=\"emoji emoji(.{1,10})\"></span>", text);
    StringBuilder sb        = new StringBuilder();
    int           lastStart = 0;
    while (m.find()) {
        String str = m.group(1);
        if (str.length() == 6) {

        } else if (str.length() == 10) {

        } else {
            str = "&#x" + str + ";";
            String tmp = text.substring(lastStart, m.start());
            sb.append(tmp + str);
            lastStart = m.end();
        }
    }
    if (lastStart < text.length()) {
        sb.append(text.substring(lastStart));
    }
    if (sb.length() > 0) {
        return EmojiParser.parseToUnicode(sb.toString());
    }
    return text;
}
 
开发者ID:biezhi,项目名称:wechat-api,代码行数:26,代码来源:WeChatUtils.java

示例3: say

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void say(String message) {
    message = EmojiParser.parseToUnicode(message);
    if (message.startsWith(".timeout ")) { //check if the message starts with a "." for timeouts. ".timeout <user>".
        sendQueue.add(new Message(message));
        return;
    }
    messages.add(new Message(message));
}
 
开发者ID:GloriousEggroll,项目名称:quorrabot,代码行数:9,代码来源:Session.java

示例4: transform

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
@Override
public FirehoseMessage transform(FirehoseMessage firehoseMessage) {
    FirehoseMessage msg = (FirehoseMessage) firehoseMessage.clone();
    msg.content = msg.content.replaceAll(":slightly_smiling_face:", ":smile:");
    msg.content = EmojiParser.parseToUnicode(msg.content);
    return msg;
}
 
开发者ID:dmitriid,项目名称:tetrad,代码行数:8,代码来源:TransformSlackSmileys.java

示例5: parseEmojis

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
/**
 * Replaces emoji codes within the text with unicode emojis.
 *
 * Note that an emoji code must be surrounded on both sides by one of:
 *
 * - whitespace (i.e. ' ' or '\t')
 * - punctuation (one of [.,;:"'?!])
 * - the beginning or end of the string
 */
public static String parseEmojis(String body) {
    if (TextUtils.isEmpty(body)) {
        return body;
    }

    // whitespace and punctuation characters
    String ACCEPTED_CHARS = "[\\s.,?:;'\"!]";

    // explanation: we want to match:
    // 1) either an accepted char or the beginning of the text (i.e. ^)
    // 2) the actual emoji code (to be inserted in the loop)
    // 3) either an accepted char or the end of the text (i.e. $)
    String REGEX_TEMPLATE = String.format("(^|%s)%s(%s|$)", ACCEPTED_CHARS, "%s", ACCEPTED_CHARS);

    // iterate over all the entries
    for (Map.Entry<String, String> entry : EmojiRegistry.EMOJIS_MAP.entrySet()) {
        // quote the emoji code because some characters like ) are protected in regex land
        String quoted = Pattern.quote(entry.getKey());
        String regex = String.format(REGEX_TEMPLATE, quoted);

        // the $1 and $2 represent the character* that came before the emoji and the
        // character* that came after the emoji
        // * - or beginning / end of text
        body = body.replaceAll(regex, "$1:" + entry.getValue() + ":$2");
    }

    return EmojiParser.parseToUnicode(body);
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:38,代码来源:EmojiRegistry.java

示例6: Op

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public Op(@NotNull OpType type,
          @Nullable String symbol,
          @Nullable String keyword,
          @NotNull String name,
          boolean reserved,
          boolean reactive,
          @Nullable String bnf,
          int priority,
          @Nullable Boolean pure,
          @NotNull SourceNodeOptions nodeOptions,
          @Nullable String emoji,
          @Nullable Function<Value[], Type> typeFunction) {
    this.type = type;
    this.typeFunction = typeFunction;
    if (emoji != null) {
        this.emoji = EmojiParser.parseToUnicode(emoji);
    }
    this.symbol = symbol;
    this.keyword = keyword;
    this.name = name;
    this.reserved = reserved;
    this.reactive = reactive;
    this.bnf = bnf;
    this.priority = priority;
    this.pure = pure;
    this.nodeOptions = nodeOptions;

    if (!reserved && (priority == 0)) {
        throw new AssertionError("Priority must be > 0");
    }
}
 
开发者ID:sillelien,项目名称:dollar,代码行数:32,代码来源:Op.java

示例7: testWhitespaceBothSides

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testWhitespaceBothSides() {
    String src = " :) ";
    String expected = EmojiParser.parseToUnicode(" :" + Emojis.SMILEY + ": ");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例8: testJustEmoji

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testJustEmoji() {
    String src = ":)";
    String expected = EmojiParser.parseToUnicode(":" + Emojis.SMILEY + ":");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例9: testPunctuationNothing

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testPunctuationNothing() {
    String src = ".:)";
    String expected = EmojiParser.parseToUnicode(".:" + Emojis.SMILEY + ":");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例10: testNothingPunctuation

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testNothingPunctuation() {
    String src = ":)!";
    String expected = EmojiParser.parseToUnicode(":" + Emojis.SMILEY + ":!");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例11: testPunctuationPunctuation

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testPunctuationPunctuation() {
    String src = ".:)!!!";
    String expected = EmojiParser.parseToUnicode(".:" + Emojis.SMILEY + ":!!!");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例12: testMultipleEmojisOnlyReplaceFirst

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testMultipleEmojisOnlyReplaceFirst() {
    String src = ":):):)";
    String expected = EmojiParser.parseToUnicode(":" + Emojis.SMILEY + "::):)");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例13: testNewlineAfter

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testNewlineAfter() {
    String src = ":)\n";
    String expected = EmojiParser.parseToUnicode(":" + Emojis.SMILEY + ":\n");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例14: testNewlineNewline

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
public void testNewlineNewline() {
    String src = "\n:)\n";
    String expected = EmojiParser.parseToUnicode("\n:" + Emojis.SMILEY + ":\n");
    assertEquals(EmojiParser.parseToUnicode(expected), EmojiRegistry.parseEmojis(src));
}
 
开发者ID:moezbhatti,项目名称:qksms,代码行数:6,代码来源:EmojiRegistryTest.java

示例15: emoji

import com.vdurmont.emoji.EmojiParser; //导入方法依赖的package包/类
/**
 * An :grinning:awesome :smiley:string &#128516;with a few :wink:emojis!
 * <p>
 * 这种格式的字符转换为emoji表情
 *
 * @param value
 * @return
 */
public static String emoji(String value) {
    return EmojiParser.parseToUnicode(value);
}
 
开发者ID:ZHENFENG13,项目名称:My-Blog,代码行数:12,代码来源:Commons.java


注:本文中的com.vdurmont.emoji.EmojiParser.parseToUnicode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。