Text::Emoji

Provide :text: to emoji translation

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.

Text::Emoji v0.0.11

Provide :text: to emoji translation

Authors

  • Elizabeth Mattijsen

License

Artistic-2.0

Dependencies

Map::Match:ver<0.0.10+>:auth<zef:lizmat>

Test Dependencies

Provides

  • Text::Emoji

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.