Code Monkey home page Code Monkey logo

flag-emoji-replacements's Introduction

Interesting flag emoji replacements

@iwsfutcmd shared an interesting observation:

'๐Ÿ‡ง๐Ÿ‡ฌ๐Ÿ‡ญ๐Ÿ‡ท'.replace('๐Ÿ‡ฌ๐Ÿ‡ญ', '๐Ÿ‡ฆ๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡ง๐Ÿ‡ฆ๐Ÿ‡ฌ๐Ÿ‡ท'

This repository contains every possible variation of this gotcha according to Unicode 15.1.0โ€™s RGI_Emoji_Flag_Sequence. Thereโ€™s 9,211,570 different variations clocking in at 718.53 MB, so the output is split across multiple files.

Examples:

'๐Ÿ‡ป๐Ÿ‡ฆ๐Ÿ‡ฉ๐Ÿ‡ฒ'.replace('๐Ÿ‡ฆ๐Ÿ‡ฉ', '๐Ÿ‡ฌ๐Ÿ‡บ'); // โ†’ '๐Ÿ‡ป๐Ÿ‡ฌ๐Ÿ‡บ๐Ÿ‡ฒ'
'๐Ÿ‡ฐ๐Ÿ‡ท๐Ÿ‡ช๐Ÿ‡น'.replace('๐Ÿ‡ท๐Ÿ‡ช', '๐Ÿ‡ณ๐Ÿ‡ฑ'); // โ†’ '๐Ÿ‡ฐ๐Ÿ‡ณ๐Ÿ‡ฑ๐Ÿ‡น'
'๐Ÿ‡จ๐Ÿ‡ต๐Ÿ‡ธ๐Ÿ‡จ'.replace('๐Ÿ‡ต๐Ÿ‡ธ', '๐Ÿ‡ป๐Ÿ‡จ'); // โ†’ '๐Ÿ‡จ๐Ÿ‡ป๐Ÿ‡จ๐Ÿ‡จ'
'๐Ÿ‡ง๐Ÿ‡ง๐Ÿ‡ธ๐Ÿ‡ฑ'.replace('๐Ÿ‡ง๐Ÿ‡ธ', '๐Ÿ‡ช๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ฌ๐Ÿ‡ฑ'
'๐Ÿ‡ฆ๐Ÿ‡น๐Ÿ‡จ๐Ÿ‡บ'.replace('๐Ÿ‡น๐Ÿ‡จ', '๐Ÿ‡ธ๐Ÿ‡ฒ'); // โ†’ '๐Ÿ‡ฆ๐Ÿ‡ธ๐Ÿ‡ฒ๐Ÿ‡บ'
'๐Ÿ‡ฌ๐Ÿ‡ฑ๐Ÿ‡ฆ๐Ÿ‡ช'.replace('๐Ÿ‡ฑ๐Ÿ‡ฆ', '๐Ÿ‡ฎ๐Ÿ‡ช'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡ฎ๐Ÿ‡ช๐Ÿ‡ช'
'๐Ÿ‡ฑ๐Ÿ‡ธ๐Ÿ‡ฒ๐Ÿ‡ญ'.replace('๐Ÿ‡ธ๐Ÿ‡ฒ', '๐Ÿ‡ฐ๐Ÿ‡ช'); // โ†’ '๐Ÿ‡ฑ๐Ÿ‡ฐ๐Ÿ‡ช๐Ÿ‡ญ'
'๐Ÿ‡น๐Ÿ‡ป๐Ÿ‡ฆ๐Ÿ‡ซ'.replace('๐Ÿ‡ป๐Ÿ‡ฆ', '๐Ÿ‡จ๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡น๐Ÿ‡จ๐Ÿ‡ฌ๐Ÿ‡ซ'
'๐Ÿ‡ฌ๐Ÿ‡ญ๐Ÿ‡ท๐Ÿ‡บ'.replace('๐Ÿ‡ญ๐Ÿ‡ท', '๐Ÿ‡ธ๐Ÿ‡ญ'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡ธ๐Ÿ‡ญ๐Ÿ‡บ'
'๐Ÿ‡ฆ๐Ÿ‡ฌ๐Ÿ‡ซ๐Ÿ‡ฎ'.replace('๐Ÿ‡ฌ๐Ÿ‡ซ', '๐Ÿ‡ฑ๐Ÿ‡ธ'); // โ†’ '๐Ÿ‡ฆ๐Ÿ‡ฑ๐Ÿ‡ธ๐Ÿ‡ฎ'
'๐Ÿ‡ฌ๐Ÿ‡ธ๐Ÿ‡ฎ๐Ÿ‡น'.replace('๐Ÿ‡ธ๐Ÿ‡ฎ', '๐Ÿ‡น๐Ÿ‡ฑ'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡น๐Ÿ‡ฑ๐Ÿ‡น'
'๐Ÿ‡ฌ๐Ÿ‡ฎ๐Ÿ‡ธ๐Ÿ‡ฌ'.replace('๐Ÿ‡ฎ๐Ÿ‡ธ', '๐Ÿ‡ง๐Ÿ‡ง'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ง๐Ÿ‡ฌ'
'๐Ÿ‡น๐Ÿ‡น๐Ÿ‡ฒ๐Ÿ‡ฆ'.replace('๐Ÿ‡น๐Ÿ‡ฒ', '๐Ÿ‡ฌ๐Ÿ‡น'); // โ†’ '๐Ÿ‡น๐Ÿ‡ฌ๐Ÿ‡น๐Ÿ‡ฆ'
'๐Ÿ‡ฌ๐Ÿ‡ผ๐Ÿ‡ซ๐Ÿ‡ฒ'.replace('๐Ÿ‡ผ๐Ÿ‡ซ', '๐Ÿ‡ง๐Ÿ‡ฏ'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡ง๐Ÿ‡ฏ๐Ÿ‡ฒ'
'๐Ÿ‡จ๐Ÿ‡ฐ๐Ÿ‡ฌ๐Ÿ‡ฆ'.replace('๐Ÿ‡ฐ๐Ÿ‡ฌ', '๐Ÿ‡ฒ๐Ÿ‡จ'); // โ†’ '๐Ÿ‡จ๐Ÿ‡ฒ๐Ÿ‡จ๐Ÿ‡ฆ'
'๐Ÿ‡ฒ๐Ÿ‡ณ๐Ÿ‡ฆ๐Ÿ‡ด'.replace('๐Ÿ‡ณ๐Ÿ‡ฆ', '๐Ÿ‡ซ๐Ÿ‡ฎ'); // โ†’ '๐Ÿ‡ฒ๐Ÿ‡ซ๐Ÿ‡ฎ๐Ÿ‡ด'
'๐Ÿ‡ช๐Ÿ‡ฆ๐Ÿ‡ฎ๐Ÿ‡จ'.replace('๐Ÿ‡ฆ๐Ÿ‡ฎ', '๐Ÿ‡ญ๐Ÿ‡ฒ'); // โ†’ '๐Ÿ‡ช๐Ÿ‡ญ๐Ÿ‡ฒ๐Ÿ‡จ'
'๐Ÿ‡ฎ๐Ÿ‡น๐Ÿ‡น๐Ÿ‡ญ'.replace('๐Ÿ‡น๐Ÿ‡น', '๐Ÿ‡ณ๐Ÿ‡ช'); // โ†’ '๐Ÿ‡ฎ๐Ÿ‡ณ๐Ÿ‡ช๐Ÿ‡ญ'
'๐Ÿ‡ต๐Ÿ‡ฌ๐Ÿ‡บ๐Ÿ‡ฌ'.replace('๐Ÿ‡ฌ๐Ÿ‡บ', '๐Ÿ‡ฒ๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡ต๐Ÿ‡ฒ๐Ÿ‡ฌ๐Ÿ‡ฌ'
'๐Ÿ‡ฑ๐Ÿ‡ธ๐Ÿ‡ธ๐Ÿ‡ฝ'.replace('๐Ÿ‡ธ๐Ÿ‡ธ', '๐Ÿ‡ฐ๐Ÿ‡ฒ'); // โ†’ '๐Ÿ‡ฑ๐Ÿ‡ฐ๐Ÿ‡ฒ๐Ÿ‡ฝ'
'๐Ÿ‡บ๐Ÿ‡พ๐Ÿ‡น๐Ÿ‡ป'.replace('๐Ÿ‡พ๐Ÿ‡น', '๐Ÿ‡ฒ๐Ÿ‡ฒ'); // โ†’ '๐Ÿ‡บ๐Ÿ‡ฒ๐Ÿ‡ฒ๐Ÿ‡ป'
'๐Ÿ‡ธ๐Ÿ‡ช๐Ÿ‡น๐Ÿ‡ฉ'.replace('๐Ÿ‡ช๐Ÿ‡น', '๐Ÿ‡ฑ๐Ÿ‡จ'); // โ†’ '๐Ÿ‡ธ๐Ÿ‡ฑ๐Ÿ‡จ๐Ÿ‡ฉ'
'๐Ÿ‡ฌ๐Ÿ‡ช๐Ÿ‡ธ๐Ÿ‡ญ'.replace('๐Ÿ‡ช๐Ÿ‡ธ', '๐Ÿ‡ธ๐Ÿ‡น'); // โ†’ '๐Ÿ‡ฌ๐Ÿ‡ธ๐Ÿ‡น๐Ÿ‡ญ'
'๐Ÿ‡ธ๐Ÿ‡ฉ๐Ÿ‡ฒ๐Ÿ‡ฌ'.replace('๐Ÿ‡ฉ๐Ÿ‡ฒ', '๐Ÿ‡ฌ๐Ÿ‡ช'); // โ†’ '๐Ÿ‡ธ๐Ÿ‡ฌ๐Ÿ‡ช๐Ÿ‡ฌ'
'๐Ÿ‡ธ๐Ÿ‡ฒ๐Ÿ‡ฆ๐Ÿ‡ฎ'.replace('๐Ÿ‡ฒ๐Ÿ‡ฆ', '๐Ÿ‡ง๐Ÿ‡ณ'); // โ†’ '๐Ÿ‡ธ๐Ÿ‡ง๐Ÿ‡ณ๐Ÿ‡ฎ'

To get a random example:

shuf -n 1 < output/$(ls output/ | shuf -n 1)

The general pattern is the following, where A, B, C, D, E, and F are all flag emoji, and {A, B} are distinct from {C, D, E, F}:

'AB'.replace('C', 'D'); // โ†’ 'EF'

Note that {C, D} may overlap with {E, F}, as that leads to even more confusing results, e.g.:

'๐Ÿ‡ฒ๐Ÿ‡ฆ๐Ÿ‡ธ๐Ÿ‡ฑ'.replace('๐Ÿ‡ฆ๐Ÿ‡ธ', '๐Ÿ‡ฒ๐Ÿ‡ฒ'); // โ†’ '๐Ÿ‡ฒ๐Ÿ‡ฒ๐Ÿ‡ฒ๐Ÿ‡ฑ'

Explanation

Unicode defines the following 26 Regional_Indicator symbols:

๐Ÿ‡ฆ ๐Ÿ‡ง ๐Ÿ‡จ ๐Ÿ‡ฉ ๐Ÿ‡ช ๐Ÿ‡ซ ๐Ÿ‡ฌ ๐Ÿ‡ญ ๐Ÿ‡ฎ ๐Ÿ‡ฏ ๐Ÿ‡ฐ ๐Ÿ‡ฑ ๐Ÿ‡ฒ ๐Ÿ‡ณ ๐Ÿ‡ด ๐Ÿ‡ต ๐Ÿ‡ถ ๐Ÿ‡ท ๐Ÿ‡ธ ๐Ÿ‡น ๐Ÿ‡บ ๐Ÿ‡ป ๐Ÿ‡ผ ๐Ÿ‡ฝ ๐Ÿ‡พ ๐Ÿ‡ฟ

Combining two of these into a country code results in the flag emoji for that country. So, @iwsfutcmdโ€™s example:

'๐Ÿ‡ง๐Ÿ‡ฌ๐Ÿ‡ญ๐Ÿ‡ท'.replace('๐Ÿ‡ฌ๐Ÿ‡ญ', '๐Ÿ‡ฆ๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡ง๐Ÿ‡ฆ๐Ÿ‡ฌ๐Ÿ‡ท'

โ€ฆis actually the following (with spaces added for clarity):

'๐Ÿ‡ง ๐Ÿ‡ฌ ๐Ÿ‡ญ ๐Ÿ‡ท'.replace('๐Ÿ‡ฌ ๐Ÿ‡ญ', '๐Ÿ‡ฆ ๐Ÿ‡ฌ'); // โ†’ '๐Ÿ‡ง ๐Ÿ‡ฆ ๐Ÿ‡ฌ ๐Ÿ‡ท'

The code replaces the second half (๐Ÿ‡ฌ) of the first flag emoji (๐Ÿ‡ง๐Ÿ‡ฌ) and the first half (๐Ÿ‡ญ) of the second flag emoji (๐Ÿ‡ญ๐Ÿ‡ท), thus changing both the first and second emoji.

flag-emoji-replacements's People

Contributors

mathiasbynens avatar iwsfutcmd avatar

Stargazers

Manuel Spigolon avatar Joรฃo Palmeiro avatar Sung Jeon avatar Dongsung "Donny" Kim avatar Antony avatar Eduardo de Diego Lucas avatar  avatar Jonatan Witoszek avatar Summy avatar Takuya Murao avatar Michel Mariani avatar Konstantin Vyatkin avatar Locke Bircher avatar ็ˆฑๅฏๅฏ-็ˆฑ็”Ÿๆดป avatar Xinhao Luo avatar Skurikhin Alexandr avatar Ilyas LEFEBVRE avatar Rob Garrison avatar  avatar Tksi avatar Josey C. Wรถrmann avatar MooYeol Prescott Lee avatar Sunny avatar Christian Grรธngaard avatar Andrew Gurylev avatar Jona Abdinghoff avatar pongstr avatar Stephen โ™” ร“ Conchubhair avatar Francisco Lucas avatar Aviskar KC avatar Arthur Melo avatar Erik avatar Daniel Tomlinson avatar  avatar Clรฉment P avatar Dmitrii Korostelev avatar Arturs Jansons avatar Junwoo avatar

Watchers

 avatar James Cloos avatar  avatar

Forkers

iwsfutcmd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.