{"id":13468405,"url":"https://github.com/mathiasbynens/flag-emoji-replacements","last_synced_at":"2025-10-09T23:02:42.265Z","repository":{"id":45370391,"uuid":"438947820","full_name":"mathiasbynens/flag-emoji-replacements","owner":"mathiasbynens","description":"'🇩🇰🇲🇬'.replace('🇰🇲', '🇪🇨'); // → '🇩🇪🇨🇬'","archived":false,"fork":false,"pushed_at":"2025-01-21T15:49:32.000Z","size":72655,"stargazers_count":37,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T16:41:42.796Z","etag":null,"topics":["javascript","unicode"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathiasbynens.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-16T10:24:33.000Z","updated_at":"2025-02-11T15:51:31.000Z","dependencies_parsed_at":"2025-03-03T09:41:17.372Z","dependency_job_id":null,"html_url":"https://github.com/mathiasbynens/flag-emoji-replacements","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mathiasbynens/flag-emoji-replacements","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiasbynens%2Fflag-emoji-replacements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiasbynens%2Fflag-emoji-replacements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiasbynens%2Fflag-emoji-replacements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiasbynens%2Fflag-emoji-replacements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathiasbynens","download_url":"https://codeload.github.com/mathiasbynens/flag-emoji-replacements/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathiasbynens%2Fflag-emoji-replacements/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002125,"owners_count":26083316,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","unicode"],"created_at":"2024-07-31T15:01:10.234Z","updated_at":"2025-10-09T23:02:38.378Z","avatar_url":"https://github.com/mathiasbynens.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Interesting flag emoji replacements\n\n[@iwsfutcmd](https://github.com/iwsfutcmd) [shared an interesting observation](https://twitter.com/iwsfutcmd/status/1471250563677388800):\n\n```js\n'🇧🇬🇭🇷'.replace('🇬🇭', '🇦🇬'); // → '🇧🇦🇬🇷'\n```\n\nThose flags are:\n\n```\n'${Bulgaria} ${Croatia}'.replace('${Ghana}', '${Antigua \u0026 Barbuda}'); // → '${Bosnia \u0026 Herzegovina} ${Greece}'\n```\n\nThis repository contains every possible variation of this gotcha according to Unicode 16.0.0’s `RGI_Emoji_Flag_Sequence`. There’s [9,351,188 different variations clocking in at 729.42 MB](https://github.com/mathiasbynens/flag-emoji-replacements/tree/main/output), so the output is split across multiple files.\n\nExamples:\n\n```js\n'🇻🇦🇩🇲'.replace('🇦🇩', '🇬🇺'); // → '🇻🇬🇺🇲'\n'🇰🇷🇪🇹'.replace('🇷🇪', '🇳🇱'); // → '🇰🇳🇱🇹'\n'🇨🇵🇸🇨'.replace('🇵🇸', '🇻🇨'); // → '🇨🇻🇨🇨'\n'🇧🇧🇸🇱'.replace('🇧🇸', '🇪🇬'); // → '🇧🇪🇬🇱'\n'🇦🇹🇨🇺'.replace('🇹🇨', '🇸🇲'); // → '🇦🇸🇲🇺'\n'🇬🇱🇦🇪'.replace('🇱🇦', '🇮🇪'); // → '🇬🇮🇪🇪'\n'🇱🇸🇲🇭'.replace('🇸🇲', '🇰🇪'); // → '🇱🇰🇪🇭'\n'🇹🇻🇦🇫'.replace('🇻🇦', '🇨🇬'); // → '🇹🇨🇬🇫'\n'🇬🇭🇷🇺'.replace('🇭🇷', '🇸🇭'); // → '🇬🇸🇭🇺'\n'🇦🇬🇫🇮'.replace('🇬🇫', '🇱🇸'); // → '🇦🇱🇸🇮'\n'🇬🇸🇮🇹'.replace('🇸🇮', '🇹🇱'); // → '🇬🇹🇱🇹'\n'🇬🇮🇸🇬'.replace('🇮🇸', '🇧🇧'); // → '🇬🇧🇧🇬'\n'🇹🇹🇲🇦'.replace('🇹🇲', '🇬🇹'); // → '🇹🇬🇹🇦'\n'🇬🇼🇫🇲'.replace('🇼🇫', '🇧🇯'); // → '🇬🇧🇯🇲'\n'🇨🇰🇬🇦'.replace('🇰🇬', '🇲🇨'); // → '🇨🇲🇨🇦'\n'🇲🇳🇦🇴'.replace('🇳🇦', '🇫🇮'); // → '🇲🇫🇮🇴'\n'🇪🇦🇮🇨'.replace('🇦🇮', '🇭🇲'); // → '🇪🇭🇲🇨'\n'🇮🇹🇹🇭'.replace('🇹🇹', '🇳🇪'); // → '🇮🇳🇪🇭'\n'🇵🇬🇺🇬'.replace('🇬🇺', '🇲🇬'); // → '🇵🇲🇬🇬'\n'🇱🇸🇸🇽'.replace('🇸🇸', '🇰🇲'); // → '🇱🇰🇲🇽'\n'🇺🇾🇹🇻'.replace('🇾🇹', '🇲🇲'); // → '🇺🇲🇲🇻'\n'🇸🇪🇹🇩'.replace('🇪🇹', '🇱🇨'); // → '🇸🇱🇨🇩'\n'🇬🇪🇸🇭'.replace('🇪🇸', '🇸🇹'); // → '🇬🇸🇹🇭'\n'🇸🇩🇲🇬'.replace('🇩🇲', '🇬🇪'); // → '🇸🇬🇪🇬'\n'🇸🇲🇦🇮'.replace('🇲🇦', '🇧🇳'); // → '🇸🇧🇳🇮'\n```\n\nTo get a random example:\n\n```sh\nshuf -n 1 \u003c output/$(ls output/ | shuf -n 1)\n```\n\nThe 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}`:\n\n```js\n'AB'.replace('C', 'D'); // → 'EF'\n```\n\nNote that `{C, D}` may overlap with `{E, F}`, as that leads to even more confusing results, e.g.:\n\n```js\n'🇲🇦🇸🇱'.replace('🇦🇸', '🇲🇲'); // → '🇲🇲🇲🇱'\n```\n\n## Explanation\n\nUnicode defines the following 26 `Regional_Indicator` symbols:\n\n```\n🇦 🇧 🇨 🇩 🇪 🇫 🇬 🇭 🇮 🇯 🇰 🇱 🇲 🇳 🇴 🇵 🇶 🇷 🇸 🇹 🇺 🇻 🇼 🇽 🇾 🇿\n```\n\nCombining two of these into a [country code](https://unicode.org/reports/tr51/#Flags \"Unicode region subtag\") results in the flag emoji for that country. So, @iwsfutcmd’s example:\n\n```js\n'🇧🇬🇭🇷'.replace('🇬🇭', '🇦🇬'); // → '🇧🇦🇬🇷'\n```\n\n…is actually the following (with spaces added for clarity):\n\n```js\n'🇧 🇬 🇭 🇷'.replace('🇬 🇭', '🇦 🇬'); // → '🇧 🇦 🇬 🇷'\n```\n\nThe 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasbynens%2Fflag-emoji-replacements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathiasbynens%2Fflag-emoji-replacements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathiasbynens%2Fflag-emoji-replacements/lists"}