README
NAME
Text::Emoji - provide :text: to emoji translation
SYNOPSIS
use Text::Emoji;
say to-emoji("I :heart: :beer:"); # I โค๏ธ ๐บ
say to-text(":I: โค๏ธ ๐บ"); # I :heart: :beer:DESCRIPTION
The Text::Emoji distribution contains information about transforming :text: to emoji transliteration. As such it exports a number of subroutines.
It also installs a convenience script em that will convert to emojis any arguments from the command line or from standard input.
SUBROUTINES
to-emoji
say to-emoji("I :heart: :beer:"); # I โค๏ธ ๐บ
say to-emoji("I :love: :beer:", :love<โค๏ธ>); # I โค๏ธ ๐บ
say to-emoji("I :love: :beer:", :love<heart>); # I โค๏ธ ๐บ
say to-emoji("I :love: :beer:", %(love => "โค๏ธ")); # I โค๏ธ ๐บ
say to-emoji("I :love: :beer:", %(love => "heart")); # I โค๏ธ ๐บ
say to-emoji("baby: :baby-bottle::babybottle:"); # baby: ๐ผ๐ผThe to-emoji subroutine in its simplest form takes a string as the first argument and attempt to transform any known emoji strings of the form :word: into the associated emoji. Note that the word may contain hyphens, but they are optional.
Additional mapping info may be specified as additional named arguments, or as a hash. The value for each additional mapping may be either the emoji directly, or the text equivalent of the emoji. Note that all text in these additional mappings, should be in lowercase only.
to-text
say to-text("I โค๏ธ ๐บ"); # I :heart: :beer:
say to-text("I โค๏ธ ๐บ", :love<โค๏ธ>); # I :love: :beer:
say to-text("I โค๏ธ ๐บ", :love<heart>); # I :love: :beer:
say to-text("I โค๏ธ ๐บ", %(love => "โค๏ธ")); # I :love: :beer:
say to-text("I โค๏ธ ๐บ", %(love => "heart")); # I :love: :beer:The to-text subroutine in its simplest form takes a string as the first argument and attempt to transform any known emojis to the shortest possible :word: form known for that emoji.
The same type of additional map information as can be specified with to-emoji, can be specified with to-text.
by-tag
say by-tag<birthday>; # ๐ฅณ๐๐
say by-tag{/^wh/}; # (๐ ๐คญ ๐ฅ ๐ซ)The by-tag subroutine returns a Map::Match object with the tags found in the raw emoji data, and their associated emojis as a single string. This allows easy searching for tags by a string, but also by a regex.
raw-emoji-data
say raw-emoji-data<โค๏ธ>.keys;
# (aliases category description emoji ios_version tags unicode_version)The raw-emoji-data subroutine returns a Map, keyed to the supported emojis. The value associated with is a Map as well, which can be best described by its JSON representation:
{
"description": "red heart",
"category": "Smileys & Emotion",
"aliases": [
"heart"
],
"tags": [
"love"
],
"unicode_version": "",
"ios_version": "6.0"
}SCRIPTS
em
$ em I :heart: :beer:
I โค๏ธ ๐บ
$ echo I :heart: :beer: | em
I โค๏ธ ๐บThe em script converts any text given either on the command line, or from STDIN, to emojis where appropriate.
MAPPINGS PROVIDED
Activities
Animals & Nature
Flags
Food & Drink
Objects
People & Body
Smileys & Emotion
Symbols
Travel & Places
INSPIRATION
Inspired by Simon Harms' Avolution::Emoji module, but completely re-imagined from scratch using the table provided by the gemoji library.
AUTHOR
Elizabeth Mattijsen [email protected]
Source can be located at: https://codeberg.org/lizmat/Text-Emoji . Comments and Pull Requests are welcome.
If you like this module, or what I'm doing more generally, committing to a small sponsorship would mean a great deal to me!
COPYRIGHT AND LICENSE
Copyright 2024, 2025, 2026 Elizabeth Mattijsen
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.