Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

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

NameTypeDescription
inputstring

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 sequence
JP JP DE
NL GB JP
JP
null null
🏴󠁧󠁢󠁥󠁮󠁧󠁿

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.