About β€’ Blog β€’ Newsletter β€’ Links

Mahjong tiles and Unicode variation selectors

Published 2023-12-18 by Seth Larson
Reading time: 1 minute

It's been a while since I've written about Unicode, so here's a short one about a Unicode feature I recently learned about wrapped inside an opportunity to admire the Mahjong glyphs.

Quoting Wikipedia, Mahjong is a tile-based game that was developed in the 19th century in China and has spread throughout the world. Similar to other classic games like Chess and French Playing Cards, Mahjong has its own block in Unicode (U+1F000 - U+1F02F) for all of the tiles.

Winds (U+1F000..U+1F003)
πŸ€€πŸ€πŸ€‚πŸ€ƒ
Dragons (U+1F004..U+1F006)
πŸ€„οΈŽπŸ€…πŸ€†
Dots (U+1F019..U+1F021)
πŸ€™πŸ€šπŸ€›πŸ€œπŸ€πŸ€žπŸ€ŸπŸ€ πŸ€‘
Bamboo (U+1F010..U+1F018)
πŸ€πŸ€‘πŸ€’πŸ€“πŸ€”πŸ€•πŸ€–πŸ€—πŸ€˜
Characters (U+1F007..U+1F00F)
πŸ€‡πŸ€ˆπŸ€‰πŸ€ŠπŸ€‹πŸ€ŒπŸ€πŸ€ŽπŸ€
Flowers (U+1F022..U+1F025)
πŸ€’πŸ€£πŸ€€πŸ€₯
Seasons (U+1F026..U+1F029)
πŸ€¦πŸ€§πŸ€¨πŸ€©
Reverse (U+1F02B)
πŸ€«
Red Dragon Emoji (U+1F004)
πŸ€„

The Mahjong Unicode block has a single emoji in it: the Mahjong Red Dragon (πŸ€„). So why then does it look like text in our table instead of how emojis usually look?

This effect is achieved using a feature called Unicode variation selectors.

These codepoints are in the range U+FE00..U+FE0F. The variation selectors we're interested in today are U+FE0E and U+FE0F for β€œtext-style” and β€œemoji-style” respectively.

The variation selector works by being placed after the character being modified. So the Mahjong Red Dragon in text-style would be "πŸ€„\uFE0E" in Python. There's a giant list of codepoints that interact with the text and emoji variation characters, give them a look if you need this feature.

Thanks for reading! β™‘ Did you find this article helpful and want more content like it? Get notified of new posts by subscribing to the RSS feed or the email newsletter.


This work is licensed under CC BY-SA 4.0