Stripping Emojis

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Stripping Emojis

Post by richmond62 » Sun Jan 13, 2019 10:34 pm

This is, largely, aimed at Stephen MacLean . . .
-
Screenshot 2019-01-13 at 23.31.23.png

Code: Select all

on mouseUp
   put empty into fld "f2"
   repeat until char 1 of fld "f1" is empty
   put codePointToNum(char 1 of fld "f1") into NUMMER
   if NUMMER > 128511 then
         --do nix
      else
         put numToCodePoint(NUMMER) after fld "f2"
      end if
      delete char 1 of fld "f1"
   end repeat
   send "mouseUp" to btn "Populate"
end mouseUp
Attachments
Hard Core Stripper.livecode.zip
Here's the stack
(1.48 KiB) Downloaded 225 times

scott_morrow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 29
Joined: Tue Jun 27, 2006 8:35 pm
Location: Bellingham, WA USA
Contact:

Re: Stripping Emojis

Post by scott_morrow » Mon Jan 14, 2019 12:27 am

Hello Richmond. I've been fooling about with your emoji stripping stack. I have found that emojis cause the <open printing to pdf> command to fail silently. Being able to strip emojis would be helpful for that as well.
Using codePointToNum(tEmojiChar) > 128511 doesn't seem to catch all the emoji characters...
this cat head < 🐱 > returns "128049"

Also some emojis now have multiple skin colors < 🧜‍♂️🧜🏾‍♂️ >and that seems to throw a monkeywrench into the works, too. When I view this post in a browser, I see that the second merman is followed by a <brown swatch> and then a <male sign>. However, the second merman I pasted was actually slightly browner than the first (and looked correct when it was originally pasted) but does not seem to pass through the posting mechanism correctly. The brown swatch and male symbol seem to be incorrectly parsed away from the second merman.
Elementary Software
...now with 20% less chalk dust!

MadManSoft
Posts: 36
Joined: Fri Apr 12, 2013 9:15 pm

Re: Stripping Emojis

Post by MadManSoft » Mon Jan 14, 2019 2:39 am

Hi Richmond,

Thanks for posting this!

There are multiple ranges for emojis, as more were added in each version on Unicode.

Here is the list for the latest version of unicode 12.0

https://www.unicode.org/Public/emoji/12 ... i-data.txt

I think that between your stripper and updated unicode map, it should be able to find and strip them all?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stripping Emojis

Post by richmond62 » Mon Jan 14, 2019 9:25 am

I guess I'm a terrible snob, but I cannot understand why the Unicode consortium
are dragging themselves through the mud with their Emoji Obsession when they
should be concerning themselves with writing systems.

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Stripping Emojis

Post by SparkOut » Mon Jan 14, 2019 7:53 pm

richmond62 wrote:
Mon Jan 14, 2019 9:25 am
I guess I'm a terrible snob, but I cannot understand why the Unicode consortium
are dragging themselves through the mud with their Emoji Obsession when they
should be concerning themselves with writing systems.
absolutely exactly definitely completely utterly the thing

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stripping Emojis

Post by richmond62 » Wed Jan 16, 2019 9:58 am

On a slightly tangential note:

This:

Code: Select all

if NUMMER > 128511 then
is just fine,
but this:

Code: Select all

if NUMMER > 128511 and < 130000 then
throws a "bluey".

Can anyone teach me some basic Logic?

SparkOut
Posts: 2834
Joined: Sun Sep 23, 2007 4:58 pm

Re: Stripping Emojis

Post by SparkOut » Wed Jan 16, 2019 12:13 pm

Code: Select all

if NUMMER > 128511 and NUMMER < 130000 then 
It might be easier to visualise if each case to resolve as true/false is parenthesised so you can see what the operator is comparing

Code: Select all

if (NUMMER > 128511) and (NUMMER < 130000) then

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stripping Emojis

Post by richmond62 » Wed Jan 16, 2019 12:24 pm

For those of you who have got nothing better to do with your time:

http://www.emojitracker.com/
-
Screenshot 2019-01-16 at 13.22.28.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9249
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Stripping Emojis

Post by richmond62 » Wed Jan 16, 2019 12:25 pm

Livecode can do this far far more easily than:

https://java.wekeepcoding.com/article/2 ... m+a+string

scott_morrow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 29
Joined: Tue Jun 27, 2006 8:35 pm
Location: Bellingham, WA USA
Contact:

Re: Stripping Emojis

Post by scott_morrow » Wed Nov 17, 2021 7:40 am

A while back I ended up creating a library that can not only strip emojis but can optionally replace them in the text with an imageSource. I needed this because of bug 22982 --> PDF creation on mobile fails if the text being rendered contains an emoji. While the imageSource doesn't always display on Android (I haven't figured out why) this solution at least strips out the emojis and allows the PDF to be created more or less as expected. (It even prints nicely.) The method uses comparison against a fixed string of "known" codepoints that comprise the "base" of all emojis currently in use. This library, emojiSwapLib, is MIT license and available here: https://www.elementarysoftware.com/live ... aplib.html
Elementary Software
...now with 20% less chalk dust!

stam
Posts: 2599
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Stripping Emojis

Post by stam » Wed Nov 17, 2021 8:53 am

scott_morrow wrote:
Wed Nov 17, 2021 7:40 am
. This library, emojiSwapLib, is MIT license and available here: https://www.elementarysoftware.com/live ... aplib.html
Very nice, thanks for sharing! Will definitely check this out and have use of this (although thankfully the use of emojis is very limited amongst my users!)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”