Reference · Country and region names
flagCodefunction
The code of a flag, from any of the names a table uses for the place. Besides what the main entry's
flagCode reads (an alpha-2 or a subdivision code, in any case, and a former country's alias), this one
also reads an alpha-3 (JPN), a numeric code (392), an IOC code (GER, SUI), the place's name in
English or Japanese (Holland, UK, 日本, and katakana as hiragana), and a flag emoji. A code or a
name that two places hold (CS, England, Georgia) is null, because a near miss would draw the wrong flag.
FIFA codes are not here: Kuni does not list them.
Import it
import { flagCode } from "@johnmorrisdotca/hata/names";
Definition
function flagCode(input: string): string | null
Parameters
| Name | Type | Description |
|---|---|---|
input | string | A code, a name, or a flag emoji. |
Returns
string | null
The code as this package writes it ("JP", "JP-13", "SUHH"), or null when nothing here has that flag.
Examples
import { flagCode, flagEmoji } from "@johnmorrisdotca/hata/names";
console.log(flagCode("JPN"), flagCode("392"), flagCode("GER")); // "JP", "JP", "DE"
console.log(flagCode("Holland"), flagCode("UK"), flagCode("日本")); // "NL", "GB", "JP"
console.log(flagCode("🇯🇵")); // "JP"
console.log(flagCode("CS"), flagCode("England")); // null, null
console.log(flagEmoji("GB-ENG")); // the England tag sequenceJP JP DE
NL GB JP
JP
null null
🏴What it prints (run when this page was built)