# Emoji One
bringing you emojione.com & emoji.codes
The web's first and only complete open source emoji set. It is 100% free and super easy to integrate.
The Idea
To standardize emojis on the web through the use of common :shortnames:.
User inputted :shortnames: should be stored as-is and then replaced with the matching emoji images when outputting client side. Likewise, Unicode emojis inputted (mainly from mobiles and tablets) should be converted to their corresponding :shortname: before storing in your database.
This allows you to quickly add emoji support to your forums, guestbooks, blogs, and other web applications.
We've provided simple Javascript and PHP libraries for converting :shortnames: to emoji images, and Unicode emojis to :shortnames:. See below for usage instructions.
What Shortnames?
emoji.codes has a complete list of shortnames as well as quick copy & search functions.
Implementation
There are a couple different ways to implement Emoji One on your website. To make things as easy as possible, we've chosen to host our emoji images and Javascript library on jsDelivr. This makes it so that you never have to worry about updating the emoji images locally, because when we do updates, we'll simply push them to jsDelivr and they'll be updated on your applications.
We recommend using the PHP library for most custom applications, but implementation is completely up to you. You may use only the Javascript or PHP library or a mixture of both. Whatever you decide, we recommend that when you store user-inputted text, you make sure to store only the :shortnames:. The flow is as follows:
- The user inputs their text using shortnames and/or standard Unicode characters.
- Prior to form submission, the inputted text is converted to shortnames with the Javascript library OR after posting but before storing the text in your database, the text is converted to shortnames using the PHP library.
- When you pull the text out of your database, you can convert the :shortnames: to images prior to output using the PHP library OR after outputting, you can use the Javascript library to convert the :shortnames: to images.
Javascript Example
Below is an example of a Javascript-only implemention of Emoji One.
Include the Javascript library
<head>
<script src="//cdn.jsdelivr.net/emojione/1.0.7/lib/js/emojione.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/emojione/1.0.7/assets/css/emojione.min.css" type="text/css" media="all" />
<script type="text/javascript">
emojione.imageType = 'svg';
emojione.imagePathPNG = './../images/png/';
emojione.imagePathSVG = './../images/svg/';
</script>
</head>
On Input:
Before text is sent to your server, convert any Unicode emojis to shortnames:
<form onsubmit="convert();">
<textarea id="myTextarea">Hello World! 😄</textarea>
</form>
<script type="text/javascript">
function convert() {
var inputted = document.getElementById('myTextarea').value;
var converted = emojione.toShort(inputted);
document.getElementById('myTextarea').innerHTML = converted;
}
</script>
On Output:
<textarea id="myTextarea">Hello World! :smile:</textarea>
<script type="text/javascript">
var inputted = document.getElementById('myTextarea').value;
var converted = emojione.toImage(inputted);
document.getElementById('myTextarea').innerHTML = converted;
</script>
PHP Example
Below is an example of a PHP only implemention of Emoji One.
On Input
require('Emojione.class.php');
$string = 'Hello world! 😄';
$convertedString = Emojione::toShort($string);
On Output
require('Emojione.class.php');
Emojione::$imageType = 'svg';
Emojione::$imagePathPNG = './../images/png/';
Emojione::$imagePathSVG = './../images/svg/';
$string = 'Hello world! :smile:';
$convertedString = Emojione::toImage($string);
Considerations
Character Encoding — UTF-8
If you're getting serious about implementing emojis into your website, you will want to consider your web stack's character encoding. You should make sure that all connection points are using the same encoding. There's a lot of options and configuration possibilies here, so you'll have to figure what works best depending on your own situation.
A quick Google search will bring up a lot of information on how to get your entire web stack to use UTF-8, which is needed to properly handle Unicode emojis.
To get you started, here's a nice guide: UTF-8: The Secret of Character Encoding.
Information
Contact
If you have any questions, comments, or concerns you are welcome to contact us.
Bug reports
If you discover any bugs, feel free to create an issue on GitHub. We also welcome the open-source community to contribute to the project by forking it and issuing pull requests.
Alternatives
We sincerely hope that you choose to use Emoji One and support our project, but if you feel like it's not for you please have a look at these possible alternatives:
Licenses
Emoji One Artwork
Emoji One Non-Artwork
- Applies to the Javascript, JSON, PHP, CSS, HTML files, and everything else not covered under the artwork license above.
- License: GPL v2 or later
- Complete Legal Terms: http://www.gnu.org/licenses/gpl-2.0.html