edadma / emoji   0.1.2

ISC License GitHub

Name to character emoji translator

Scala versions: 3.x
Scala.js versions: 1.x
Scala Native versions: 0.5

emoji

Maven Central GitHub last commit GitHub Scala Version Scala.js Version Scala Native Version

A tiny, cross-platform Scala 3 lookup that turns :shortcode: syntax into the matching emoji glyph: :smile: β†’ πŸ˜„. Works on JVM, Scala.js, and Scala Native.

Install

libraryDependencies += "io.github.edadma" %%% "emoji" % "0.1.2"

Use

import io.github.edadma.emoji.Emoji

Emoji(":smile:")                    // β†’ "πŸ˜„"
Emoji("hello :smile: world :wave:") // β†’ "hello πŸ˜„ world πŸ‘‹"
Emoji(":__not_a_real_one__:")       // β†’ ":__not_a_real_one__:"  (passthrough)

Emoji.apply walks the input once with a :[a-z_]+: regex and substitutes each known shortcode for its Unicode codepoint (via Character.toChars so non-BMP code points like :heart_eyes: (U+1F60D) get the surrogate pair on the JVM).

Unknown shortcodes are left intact in the output.

Source data

The shortcode β†’ codepoint map lives in Emoji.scala (auto-generated from emoji.json at the repo root). It covers ~1,800 shortcodes drawn from the GitHub / Slack flavour of emoji.

Tests

sbt emojiJVM/test
sbt emojiJS/test
sbt emojiNative/test

License

ISC