Code Monkey home page Code Monkey logo

php-emoji's Introduction

php-emoji - Process Emoji in PHP

Build Status

This is a PHP library for dealing with Emoji, allowing you to convert between various native formats and displaying them using HTML.

You can read more about it and see a demo here: http://www.iamcal.com/emoji-in-web-apps/

The data this library is based on comes from another GitHub project: https://github.com/iamcal/emoji-data

USAGE

<?php
include('emoji.php');


# when you recieve text from a mobile device, convert it
# to the unified format.

$data = emoji_docomo_to_unified($data);   # DoCoMo devices
$data = emoji_kddi_to_unified($data);     # KDDI & Au devices
$data = emoji_softbank_to_unified($data); # Softbank & pre-iOS6 Apple devices
$data = emoji_google_to_unified($data);   # Google Android devices


# when sending data back to mobile devices, you can
# convert back to their native format.

$data = emoji_unified_to_docomo($data);   # DoCoMo devices
$data = emoji_unified_to_kddi($data);     # KDDI & Au devices
$data = emoji_unified_to_softbank($data); # Softbank & pre-iOS6 Apple devices
$data = emoji_unified_to_google($data);   # Google Android devices


# when displaying data to anyone else, you can use HTML
# to format the emoji.

$data = emoji_unified_to_html($data);

# if you want to use an editor(i.e:wysiwyg) to create the content, 
# you can use html_to_unified to store the unified value.

$data = emoji_html_to_unified(emoji_unified_to_html($data));

When using the HTML format, you'll also need to include the emoji.css file, which points to the emoji.png image.

IMPORTANT NOTE: This library currently only deals with UTF-8. If your source data is JIS or Shift-JIS, you're out of luck for the moment.

Credits

By Cal Henderson [email protected]

Images and Emoji data come from emoji-data.

This work is dual-licensed under the GPL v3 and the MIT license.

Version History

  • v1.0.0 - 2009-10-20 : First release
  • v1.2.0 - 2011-03-27 : ?
  • v1.3.0 - 2011-07-27 : ?
  • v1.4.0 - 2016-02-15 : Switch to using emoji-data as the backend, at v2.4.0
  • v1.4.1 - 2016-10-06 : Added emoji_contains_emoji(), added travis
  • v1.4.2 - 2017-03-03 : Support for unified modifiers when converting to/from HTML only (issue #34)

php-emoji's People

Contributors

albertoleal avatar chadillac avatar fieu avatar fossabot avatar iamcal avatar mdoelker avatar phoenix-mstu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-emoji's Issues

Not working.

I recently included tested this on my localhost (using xampp) but the functions are returning the same values-- I expect them to be emoji's.

On my headers are:

and
link rel="stylesheet" type="text/css" media="all" href="emoji/emoji.css"

function_notworking

e-82C to e-837 are broken - they are multi-codepoint sequences

From an email conversation with 杜志刚:

On 3/27/2011 9:23 PM, 杜志刚 wrote:

Please see
http://www.unicode.org/~scherer/emoji4unicode/snapshot/full.html#e-82C (e-82C
~ e-837)
There are BAD multiple code points :

|| num   ||chr|| first       || second   ||
|| e-82C || # || U+0023  || U+20E3 ||
|| e-82E || 1 || U+0031  || U+20E3 ||
|| e-82F || 2 || U+0032  || U+20E3 ||
...
|| e-837 || 0 || U+0030  || U+20E3 ||

The second code is BAD !

Ahhh! Now I understand what's happening here. U+20E3 is 'COMBINING ENCLOSING KEYCAP' and it draws a box around the character that comes before it, so the sequence "U+0032 U+20E3" displays a '2' in a square box, which is what we want. I think I want to modify the parser to use the sequence of 2 unicode codepoints instead of just one or the other.

The problem with using the first one is that it replaces characters where you don't expect it to - it will replace any numbers in text with the numbers-in-boxes emoji, which is almost never what you want (and the reason I changed it to begin with).

--cal

Problem to send Camera Emoji in Push Notification

Hey folks,

I am sending camera emoji in push notification. I have defined the following code for sending apns:

"\uD83D\uDCF7 Image"

The use of this code is successful and i can easily watch the camera icon in the payload . See below:

payload

I can see the camera image but when receiving the push notification, it shows:

?? image

Please help me on this

False positives for emoji_contains_emoji

The using emoji_contains_emoji I noticed a number of maybe false positives, it's up for debate as you could use many of these symbols as emoji. Since I was working with a larger source of user generated content I opted to retrieve valid sources of emoji and Unicode characters. The following is the test scripts.
https://github.com/charlesverge/emoji-php-comparsion

Two examples are

Detected as emoji ⤂

Not detected 3️⃣ as emoji

Not sure if any thing should be changed other than adding a few more emoji into the data set as the false positives for the most part look fine as emoji.

Some emoticons leave residual data in the string after conversion

I use emoji_unified_to_html
When I convert ❤️️ I have as result :
<span class="emoji-outer emoji-sizer"><span class="emoji-inner emoji2764"></span></span>️️
with some residual data : EF B8 8F EF B8 8F

This emoji is supported by this replacement :
"\xe2\x9d\xa4"=>"<span class=\x22emoji-outer emoji-sizer\x22><span class=\x22emoji-inner emoji2764\x22></span></span>",

but it seems that ❤️️ = \xe2\x9d\xa4\xef\xb8\x8f\xef\xb8\x8f not only \xe2\x9d\xa4

generate a map with the latest emoji available

Hi @iamcal
I noticed that "http://www.unicode.org/~scherer/emoji4unicode/snapshot/full.html" is outdated and dosen't contains all emoji available in gemoji. I checked also emoji-data which is based on the same file "full.html" but also on "http://www.unicode.org/Public/UNIDATA/UnicodeData.txt" which is updated with all the missing emoji.
my request is : could you please integrate the same process of emoji-data in php-emoji in order to generate a map with the latest emoji
thanks

emoji1f610 wrong positioned

emoji1f610 appears slightly wrong positioned.
Changing css to .emoji1f610 { background-position: 65.1% 75% !important; } solves it.

Problem to send emoji to Push Notification

Hi everybody, I am trying to send pushnotification for ios app.
end I am having a problem to send emoji on this push.

I have this text on my database:

"\ue415 Vei na boa vou dar um tiro nesse push"

when I try to send this message to APN(https://github.com/duccio/ApnsPHP) it arrives

"? Vei na boa vou dar um tiro nesse push"

Someone know how can I convert this?

Legal status of icon set

What is the legal status of the images used for these emoticons? Are these taken directly from iOS or are they from some other source? Are they GPL licensed?

Adding extra emojis!

Parsing posts from twitter. Sometimes it adds extra emoji after some twitters emojis. I store data in MySQL with utf8mb4_general_ci collation

Emoji's don't work with APNS-PHP

I am implementing push notifications on my php server using APNS-PHP (https://github.com/duccio/ApnsPHP). I have emoji hard-coded in my php code like this...

$message = "\xf0\x9f\x93\x85" . "This is an emoji";
// do the apns-php stuff here.

Instead of the emoji, I am getting a "?" question mark.

?This is an emoji.

Then I tried using following:

$message = emoji_unified_to_softbank("\xf0\x9f\x93\x85") . "This is an emoji";

Instead of emoji, this showed the Japanese characters for the particular emoji (calendar)....

[カレンダー]This is an emoji.

Is there a workaround for this when using APNS-PHP?

emoji_name_to_unified

Why there is no emoji_name_to_unified function?
I can't understand.

    function emoji_name_to_unified($name){
            return array_flip($GLOBALS['emoji_maps']['names'])[$name];
    }   

Some Emoji Still Not Supported

I'm using:
$string = $this->emoji->emoji_to_html($string);

Here's a screen cap of the results while attempting to convert a tweet to HTML. Note how the US flag converts to HTML beautifully, but the IE flag doesn't convert at all.

image

Retina support

It looks like the image file of this project is not optimized for retina screens

Error Cannot redeclare emoji_docomo_to_unified()

I downloaded and included it.. all i did was:

include('php-emoji-master/emoji.php');

at top of the document and

while ($ergebnis->fetch())
{
for($i=0;$i<count($badword);$i++){if(strtolower($result['name'])==$badword[$i])$result['name']='Honk :o)';$result['text']=str_ireplace($badword[$i],'***',$result['text']);}$result['text']=str_ireplace('pbadwordword','password',$result['text']);
$result['text']=filterbburl(make_clickable(emoji_unified_to_html(filter($result['text']))));
print($result['text']);
}

Fatal error: Cannot redeclare emoji_docomo_to_unified() (previously declared in C:\inetpub\wwwroot\de_DE\chat\php-emoji-master\emoji.php:2055) in C:\inetpub\wwwroot\de_DE\chat\php-emoji-master\emoji.php on line 30

Any way to get around this? I need to have the loop, $result['text'] is the text in my database.

Emoji picture is too large.

Now the emoji picture size is 7,352KB
It's too large to download it when the web load the srouces.
I think split every emoji as one picture is better.

Emoji picker corresponding with this library?

Thanks you for this amazing library.

Is there any emoji picker that corresponds with this library?? I mean the picker that produce the exact span? (Then I can convert it to native emoji with this library)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.