The Alfred Emoji Pack

In the past I tried an Alfred workflow for inserting emoji, which was pretty terrible. When I upgraded my computers to Alfred 4 this weekend, I went on a hunt for a real solution and found The Alfred Emoji Pack, which is great because it uses the built-in snippets feature. After you launch Alfred, type your shortcut for Snippets (s in my case), a colon, and some text. It’ll show you suggestions and when you pick one it will be pasted in to whatever app you’re using at the time.

Screen Shot 2019-06-24 at 7.18.42 PM.png

Where it really becomes powerful is when you turn on Automatically expand snippets by keyword in Alfred.

PHP: Display Country Flag Emoji From ISO 3166-1 alpha-2 Country Codes

A couple of weeks ago I wanted to display emoji country flags from 2 letter country codes. I couldn’t find PHP examples anywhere. Character encodings confuse me, but after looking at some JavaScript examples and other PHP encoding info I was able to get something working.

$country_code = 'US'; // Uppercase
echo mb_convert_encoding( '&#' . ( 127397 + ord( $country_code[0] ) ) . ';', 'UTF-8', 'HTML-ENTITIES');
echo mb_convert_encoding( '&#' . ( 127397 + ord( $country_code[1] ) ) . ';', 'UTF-8', 'HTML-ENTITIES');

For U this prints out 🇺 and for S it prints out 🇸. When those two characters are side by side they get displayed as 🇺🇸.

If you have an improvement or this helps you out, leave a comment.

%d bloggers like this: