Created
April 6, 2026 17:29
-
-
Save max-power/ba4db4984ff55422f9b2911ac4d6ad89 to your computer and use it in GitHub Desktop.
Emojiflag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Emoji | |
| REGIONAL_OFFSET = 127397 | |
| COUNTRY_CODE_RE = /\A[A-Z]{2}\z/ | |
| module_function | |
| def flag(input) | |
| return "" unless COUNTRY_CODE_RE.match?(input) | |
| input.codepoints.map { |c| c + REGIONAL_OFFSET }.pack("U*") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment