Skip to content

Instantly share code, notes, and snippets.

@mpyne-navy
Created July 14, 2020 03:52
Show Gist options
  • Save mpyne-navy/ca7756c0eb21bc3eb5c60d3b2f163a10 to your computer and use it in GitHub Desktop.
Save mpyne-navy/ca7756c0eb21bc3eb5c60d3b2f163a10 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.018;
use utf8;
use charnames ();
use Unicode::Normalize;
use strict;
use warnings;
# https://twitter.com/senatorshoshana/status/1282865567985270785
# The emojis are images, not actual characters, but it appears possible
# to use the image name to figure out what Unicode character they are
# supposed to be
#
# To easily generate the list, use Chrome DevTools to inspect one of the
# emoji, right-click the <div> in the Elements view that contains all the <span>
# tags (each representing an emoji), and choose 'Store as Global Variable'.
# Then run this in the Javascript console:
# Array.from(temp1.querySelectorAll('span img')).map((el) => el.attributes.src.value);
my @emojis = (
"https://abs-0.twimg.com/emoji/v2/svg/1f60b.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f417.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f346.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f3ea.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f9f1.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f38e.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f619.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f3e8.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f94e.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f397.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f6af.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f1e7-1f1ec.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f460.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f955.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f95c.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f6af.svg",
"https://abs-0.twimg.com/emoji/v2/svg/27a1.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f3ab.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f38d.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f954.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f351.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f37d.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f1e7-1f1ec.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f6c5.svg",
"https://abs-0.twimg.com/emoji/v2/svg/21a9.svg",
"https://abs-0.twimg.com/emoji/v2/svg/1f5bc.svg",
);
# Form the emoji string by converting all the Unicode code points to Unicode
# characters and then joining the characters into a single string. The
# Bulgarian flag "1f1e7-1f1ec" is a combined character so needed a bit of
# special handling.
my $uni_str = join('', map {
s(^.*/) (); # Remove everything up to final /
s(\.svg$)(); # Remove .svg
my @chars = split('-', $_);
(@chars > 1)
? join('', map { charnames::string_vianame("U+$_") } @chars)
: charnames::string_vianame("U+$_");
} @emojis);
# Handle in explicitly denormalized mode
my $zzz_str = NFD($uni_str);
binmode(STDOUT, ":utf8");
say "Your string is: $zzz_str";
# Now let's loop through each character and see what it's formal Unicode name
# is
my @first_letters;
for my $char (split ('', $zzz_str)) {
my $uni_name = charnames::viacode(ord($char));
say "$char is $uni_name";
push @first_letters, substr($uni_name, 0, 1);
}
say "First letters: ", join('', @first_letters);
# This all gives me
# Your string is: πŸ˜‹πŸ—πŸ†πŸͺπŸ§±πŸŽŽπŸ˜™πŸ¨πŸ₯ŽπŸŽ—πŸš―πŸ‡§πŸ‡¬πŸ‘ πŸ₯•πŸ₯œπŸš―➑🎫🎍πŸ₯”πŸ‘πŸ½πŸ‡§πŸ‡¬πŸ›…β†©πŸ–Ό
# πŸ˜‹ is FACE SAVOURING DELICIOUS FOOD
# πŸ— is BOAR
# πŸ† is AUBERGINE
# πŸͺ is CONVENIENCE STORE
# 🧱 is BRICK
# 🎎 is JAPANESE DOLLS
# πŸ˜™ is KISSING FACE WITH SMILING EYES
# 🏨 is HOTEL
# πŸ₯Ž is SOFTBALL
# πŸŽ— is REMINDER RIBBON
# 🚯 is DO NOT LITTER SYMBOL
# πŸ‡§ is REGIONAL INDICATOR SYMBOL LETTER B
# πŸ‡¬ is REGIONAL INDICATOR SYMBOL LETTER G
# πŸ‘  is HIGH-HEELED SHOE
# πŸ₯• is CARROT
# πŸ₯œ is PEANUTS
# 🚯 is DO NOT LITTER SYMBOL
# ➑ is BLACK RIGHTWARDS ARROW
# 🎫 is TICKET
# 🎍 is PINE DECORATION
# πŸ₯” is POTATO
# πŸ‘ is PEACH
# 🍽 is FORK AND KNIFE WITH PLATE
# πŸ‡§ is REGIONAL INDICATOR SYMBOL LETTER B
# πŸ‡¬ is REGIONAL INDICATOR SYMBOL LETTER G
# πŸ›… is LEFT LUGGAGE
# ↩ is LEFTWARDS ARROW WITH HOOK
# πŸ–Ό is FRAME WITH PICTURE
# First letters: FBACBJKHSRDRRHCPDBTPPPFRRLLF
#
# Which, combine the REGIONAL INDICATOR stuff (BG) from RR into just R
# since that's a bug of this script... but that still doesn't help me
# crack the code.
# That gives FBACBJKHSRDRHCPDBTPPPFRLLF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment