Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

e4u library is bundle library for emoji4unicode

it is for handling unicode emoji and carrier’s emoji. the main feature is

  • Conversion unicode emoji to carrier’s emoji

  • Conversion carrier’s emoji to unicode emoji

The unicode emoji which this library can handle is described on http://www.unicode.org/~scherer/emoji4unicode/snapshot/full.html

This library referred to source code of emoji4unicode and django-bpmobile

Install

sudo pip install e4u

or:

sudo pip install git+git://github.com/lambdalisue/e4u.git#egg=e4u

Required (Automatically installed)

  • BeautifulSoup (for analysis carrier’s Web site and emoji4unicode.xml)

How to use

This library use emoji4unicode.xml to create conversion table of emoji. So you have to load it from filesystem or Internet. e4u.load() method load it from google code’s trunk url and recommended. if you cannot connect to internet, use e4u.load(file=r"some/path/emoji4unicode.xml") insted. The emoji4unicode.xml is found on http://code.google.com/p/emoji4unicode/source/browse/trunk/data/emoji4unicode.xml

Once you load emoji4unicode.xml, you can translate emoji with e4u.translate() method. To translate carrier’s emoji to unicode emoji, use the method like contents = e4u.translate(contents, **e4u.DOCOMO_TRANSLATE_PROFILE) To translate unicode emoji to carrier’s emoji, use the method like contents = e4u.translate(contents, reverse=True, **e4u.DOCOMO_TRANSLATE_PROFILE)

The code below describe how to use the library.:

import e4u
e4u.load()
carrier_contents = "\xF8\x9F \xF8\xA0 \xF8\xA1"         # Sun, Cloud, Rain in DoCoMo emoji
unicode_contents = u"\u2600 \u2601 \u2614"                      # Sun, Cloud, Rain in Unicode emoji

# DoCoMo => Unicode
contents = carrier_contents
expected = unicode_contents
# Translate emoji with DoCoMo profile (= {'carrier':'docomo', 'encoding':'cp932'})
result = e4u.translate(contents, **e4u.DOCOMO_TRANSLATE_PROFILE)

assert isinstance(result, unicode)              # return value is Unicode
assert result == expected

# Unicode => DoCoMo
contents = unicode_contents
expected = carrier_contents
# Translate emoji with DoCoMo profile with reverse=True
result = e4u.translate(contents, reverse=True, **e4u.DOCOMO_TRANSLATE_PROFILE)

assert isinstance(result, unicode)              # return value is Unicode
assert result.encode('cp932', 'replace') == expected

Supported carriers

Currently only DoCoMo, KDDI, SoftBank and Google is supported. the carrier name which you can pass to the e4u.translate() method is

  • text - to text

  • docomo_img - to img tag using DoCoMo emoji

  • kddi_img - to img tag using KDDI emoji (recommended for PC or other device which doesn’t support emoji)

  • softbank_img - to img tag using SoftBank emoji (not recommended, SoftBank may reject access from external so doesn’t work)

  • google - to GMail emoji. I have no idea how can I use it but in case.

  • docomo - to DoCoMo emoji. SJIS format (decoded as unicode)

  • kddi - to KDDI emoji. SJIS format (decoded as unicode)

  • softbank - to SoftBank emoji. Unicode format

Methods

e4u.load(filename=None, url=r"http://emoji4unicode.googlecode.com/svn/trunk/data/emoji4unicode.xml", loader_class=loader.Loader)

to load emoji4unicode.xml and build internal conversion table. this method never affect twice. use e4u.reload() insted to reloading library.

e4u.reload(filename=None, url=r"http://emoji4unicode.googlecode.com/svn/trunk/data/emoji4unicode.xml", loader_class=loader.Loader)

force to reload emoji4unicode.xml, use e4u.load() method insted for general use.

e4u.has_loaded()

return True if the e4u.load() method has called. use e4u.load() method insted for general use. never do like below:

# stupid way
import e4u
if not e4u.has_loaded():
    e4u.reload()

# smarter
import e4u
e4u.load()
e4u.get(id)

get emoji symbol instance for the id. the id is described on http://www.unicode.org/~scherer/emoji4unicode/snapshot/full.html strip ‘e-’ from ID like ‘000’ for ‘e-000’ and pass as unicode format.

e4u.translate(source, carrier, reverse=False, encoding=None)

translate unicode emoji contained in source to carrier’s emoji or reverse.

e4u.translate_char(source_char, carrier, reverse=False, encoding=None)

translate unicode emoji char to carrier’s emoji char. faster than e4u.translate() method but cannot handle text. use it for letter conversion.

Metadata

Release files for e4u 0.1rc2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for e4u 0.1rc2
File Size Uploaded
e4u-0.1rc2.tar.gz 50.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for e4u 0.1rc2
File Interpreter ABI Platform
e4u-0.1rc2.linux-i686.tar.gz Details
e4u-0.1rc2-py2.7.egg Legacy Egg format - - Details

Total release size: 176.6 kB

Release files / e4u-0.1rc2.tar.gz

Download URL e4u-0.1rc2.tar.gz
Size 50.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f330e0d3e9c63ced14eca7e6c7f5edb9ab58e8e0e7496bedb8dbabbe783041
BLAKE2b-256 checksum
How to use checksums
608819a2ead69f15a34f783953bb5a4ad49fa7cdce9e178ad5e0a5c575f1cf4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / e4u-0.1rc2.linux-i686.tar.gz

Download URL e4u-0.1rc2.linux-i686.tar.gz
Size 59.7 kB
Tags Source
SHA-256 checksum
How to use checksums
35b7b8cd4e947aaf712c771c6d6e0b95ceef96f1e0235f19d59c490e3e9e8824
BLAKE2b-256 checksum
How to use checksums
de86d85f1e27e09023e7d9137cff1a988213def38413e42202e190ec80e1a4fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / e4u-0.1rc2-py2.7.egg

Download URL e4u-0.1rc2-py2.7.egg
Size 66.6 kB
Tags Egg
SHA-256 checksum
How to use checksums
8a4537c4ecb9dc59d0ce0aa7b8d37af9a2b7e8aa858afad04e14e99e7359329b
BLAKE2b-256 checksum
How to use checksums
e87d823c79f0f175d285c1f01c3b196d829854ce1c7944a181ece8f488def17a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page