Emoji, again. No way to recognise unicode?

I try to recognise Emoji smileys in a string. I understand this is unicode. Is there not a smart way to check in Lua if a string contains unicode. Than a string of a native textfield could be split and for the unicodes switched to the AppleEmoji font.

And yes I allready filed a feature request for it months ago, which seems to get ignored.

:)  :angry:  :(  :smiley:

Hi.  I’m not sure if this is a Unicode thing or not.  I know many people who use UTF-8 characters in strings as long as their text editor supports them.  But it sounds like you’re trying to get this to work with the native.newTextField() API and I’m not sure what access it has to Emoji’s.

I see your request has 9 votes.  Just because we haven’t responded doesn’t mean we are ignoring the request.  We use this feedback to determine what the most popular things are that we can reasonably do.  Perhaps we need this voted up more.  I’ll ping engineering and if it’s not something doable, I’ll see if they respond. 

After reading the feature request, it sounds like they are working.  The nice big graphics are not fonts but images.  Fonts are always monochrome and it’s probably doing it’s best to find the proper symbol to show for the emote.  Getting these graphics may not be possible with display.newText, but let me see what the engineering team has to say.

This is what engineering told me:

You can actually detect if a character is an emoji icon yourself in Lua, but it’ll take quite a bit of work.

The key thing to remember here is that a string that gets pushed into Lua is UTF-8 encoded, which can be made up of both ASCII and Unicode characters.  This means that a single character can range between 1 and 4 bytes in your string.  This is why UTF-8 strings are sometimes referred to as multibytes strings.

You can identify a character in your string as a unicode character by checking its highest bit (ie: the 8th bit).  If the last bit is set, then the preceding bits indicate how many bytes represent that 1 unicode character.  This is documented here…

   http://en.wikipedia.org/wiki/UTF-8#Description

You can access the individual bytes of the string by using the following function in Lua…

   http://docs.coronalabs.com/api/library/string/byte.html

From there, you have to extract the unicode value yourself.  Once you’ve done that, you can recognize if it is an emoji icon by checking if it’s unicode character is within the range specified here…

   http://en.wikipedia.org/wiki/Emoji#Regional_Indicator_Symbols

But that said, if you’re trying to restrict the string for something like a login user name and password, then it’s simpler to restrict the characters to English characters and maybe western European character codes. 

Hey Rob thx for the inquiry. I will try it out and let you know.

Hi.  I’m not sure if this is a Unicode thing or not.  I know many people who use UTF-8 characters in strings as long as their text editor supports them.  But it sounds like you’re trying to get this to work with the native.newTextField() API and I’m not sure what access it has to Emoji’s.

I see your request has 9 votes.  Just because we haven’t responded doesn’t mean we are ignoring the request.  We use this feedback to determine what the most popular things are that we can reasonably do.  Perhaps we need this voted up more.  I’ll ping engineering and if it’s not something doable, I’ll see if they respond. 

After reading the feature request, it sounds like they are working.  The nice big graphics are not fonts but images.  Fonts are always monochrome and it’s probably doing it’s best to find the proper symbol to show for the emote.  Getting these graphics may not be possible with display.newText, but let me see what the engineering team has to say.

This is what engineering told me:

You can actually detect if a character is an emoji icon yourself in Lua, but it’ll take quite a bit of work.

The key thing to remember here is that a string that gets pushed into Lua is UTF-8 encoded, which can be made up of both ASCII and Unicode characters.  This means that a single character can range between 1 and 4 bytes in your string.  This is why UTF-8 strings are sometimes referred to as multibytes strings.

You can identify a character in your string as a unicode character by checking its highest bit (ie: the 8th bit).  If the last bit is set, then the preceding bits indicate how many bytes represent that 1 unicode character.  This is documented here…

   http://en.wikipedia.org/wiki/UTF-8#Description

You can access the individual bytes of the string by using the following function in Lua…

   http://docs.coronalabs.com/api/library/string/byte.html

From there, you have to extract the unicode value yourself.  Once you’ve done that, you can recognize if it is an emoji icon by checking if it’s unicode character is within the range specified here…

   http://en.wikipedia.org/wiki/Emoji#Regional_Indicator_Symbols

But that said, if you’re trying to restrict the string for something like a login user name and password, then it’s simpler to restrict the characters to English characters and maybe western European character codes. 

Hey Rob thx for the inquiry. I will try it out and let you know.

I have experimented with a few of Emoji Symbols and inserted them into strings

e.g

local RowIcon=display.newText(row, “:arrow_right:”, 0, -15, native.systemFontBold,27 )
                    RowIcon:setTextColor( 65, 227, 255)

works fine!!!

Even using the systemFontBold.

It does not work fine at all; they get printed in mono color and very small scaled.

The way Rob describes, I am not sure this is a good solution. My app is multi language so more letters than the normal alphabet are used. Also I wonder how this will have impact on performance when running a realtime game, chatting and a heavy analysis function on the input text.

Imo something core basic like this should just be build in Corona’s display.newText function by using Apple’s solution for it. When I look at Corona games which have a chat or message function and the emoticons dont work properly - or some weird custom non native emoticons solution has been made, it just looks totally ridiculous and amateuristic.

With all the works on Corona Cloud (though I use Noobhub), you would expect more chat / message stuff will get implemented in upcoming games.

I tried posting a screen shot here but not allowed by the forum…

If you change the font size and use the setTextColor as posted, my app shows nicely sized arrows and in turquoise bright.

Like you my first try was dissappointingly small and mono, but now I can change colors and it seems to work consistently (unless depreicated by accident in the future?)

MY App is a business app so not concerned here with performance at the moment.

As you say it could well be a concern but I also agree these (Emotions etc) should be part of Corona text support. This would allow us to have nice 'icons/emotions/Emoji Symbols in our table views as the first character and make the list look like standard apple tableview lists. I used the above code for the traditiona arrow replacement.

I have now attached a part screen capture for your interest. Emoji Arrows.tiff

Could not show all screen due to copyright content at this stage

Ye thx for reacting, but this is mono (1) color. And this works. However the Emoji are composed of multiple colors and should be able to be displayed in a string mixed with normal text at the right size.

In the attachment a screenshot of a chat module I made, which shows how a Emoji smiley currently gets displayed by Corona SDK.

Oops!          Read Emoji, thought symbols,

read  Mono, thought  old Black & White film… now seeing red :{

Maybe my suggestion of inserting symbols may have help others…

Just watching the outcome now :}

I have experimented with a few of Emoji Symbols and inserted them into strings

e.g

local RowIcon=display.newText(row, “:arrow_right:”, 0, -15, native.systemFontBold,27 )
                    RowIcon:setTextColor( 65, 227, 255)

works fine!!!

Even using the systemFontBold.

It does not work fine at all; they get printed in mono color and very small scaled.

The way Rob describes, I am not sure this is a good solution. My app is multi language so more letters than the normal alphabet are used. Also I wonder how this will have impact on performance when running a realtime game, chatting and a heavy analysis function on the input text.

Imo something core basic like this should just be build in Corona’s display.newText function by using Apple’s solution for it. When I look at Corona games which have a chat or message function and the emoticons dont work properly - or some weird custom non native emoticons solution has been made, it just looks totally ridiculous and amateuristic.

With all the works on Corona Cloud (though I use Noobhub), you would expect more chat / message stuff will get implemented in upcoming games.

I tried posting a screen shot here but not allowed by the forum…

If you change the font size and use the setTextColor as posted, my app shows nicely sized arrows and in turquoise bright.

Like you my first try was dissappointingly small and mono, but now I can change colors and it seems to work consistently (unless depreicated by accident in the future?)

MY App is a business app so not concerned here with performance at the moment.

As you say it could well be a concern but I also agree these (Emotions etc) should be part of Corona text support. This would allow us to have nice 'icons/emotions/Emoji Symbols in our table views as the first character and make the list look like standard apple tableview lists. I used the above code for the traditiona arrow replacement.

I have now attached a part screen capture for your interest. Emoji Arrows.tiff

Could not show all screen due to copyright content at this stage

Ye thx for reacting, but this is mono (1) color. And this works. However the Emoji are composed of multiple colors and should be able to be displayed in a string mixed with normal text at the right size.

In the attachment a screenshot of a chat module I made, which shows how a Emoji smiley currently gets displayed by Corona SDK.

Oops!          Read Emoji, thought symbols,

read  Mono, thought  old Black & White film… now seeing red :{

Maybe my suggestion of inserting symbols may have help others…

Just watching the outcome now :}

I have problem showing arabic letter in the simulater and app even though in CodeMAX (my editor for main.lua) it shows fine.