Code Monkey home page Code Monkey logo

java-emoji-converter's Introduction

码云Gitee Github Build Status codecov Maven Central

Java Emoji Converter(Emoji 表情转换工具)

Emoji转换工具,便于各种规格客户端生成的Emoji字符串转换成另外一种格式。

A tool to convert emoji string among each type, like softbank emoji, unicode emoji, alias emoji, html emoji.

When converting softbank emoji to unicode, we utilize this file: https://raw.githubusercontent.com/googlei18n/emoji4unicode/master/data/emoji4unicode.xml

Quick Start 快速入门

Add this in your maven pom file(将以下内容加入你的maven的pom文件中):

<dependency>
  <groupId>com.github.binarywang</groupId>
  <artifactId>java-emoji-converter</artifactId>
  <version>1.0.1</version>
</dependency>

Usage (from junit test):用法(摘自单元测试代码)

private EmojiConverter emojiConverter = EmojiConverter.getInstance();

@Test
public void testToAlias() {
    String str = "  An 😃😀awesome 😃😃string with a few 😃😉emojis!";
    String alias = this.emojiConverter.toAlias(str);
    System.out.println(str);
    System.out.println("EmojiConverterTest.testToAlias()=====>");
    System.out.println(alias);
    Assert.assertEquals(
        ":no_good: :ok_woman: :couple_with_heart:An :smiley::grinning:awesome :smiley::smiley:string with a few :smiley::wink:emojis!",
        alias);
}

@Test
public void testToHtml() {
    String str = "  An 😀😃awesome 😃😃string with a few 😉😃emojis!";
    String result = this.emojiConverter.toHtml(str);
    System.out.println(str);
    System.out.println("EmojiConverterTest.testToHtml()=====>");
    System.out.println(result);
    Assert.assertEquals(
        "&#128581; &#128582; &#128145;An &#128512;&#128515;awesome &#128515;&#128515;string with a few &#128521;&#128515;emojis!",
        result);
}

@Test
public void testToUnicode() {
    String str = "   :smiley: :grinning: :wink:";
    String result = this.emojiConverter.toUnicode(str);
    System.err.println(str);
    System.err.println("EmojiConverterTest.testToUnicode()=====>");
    System.err.println(result);
    Assert.assertEquals("🙅 🙆 💑 😃 😀 😉", result);
}

java-emoji-converter's People

Contributors

binarywang avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.