Class EmojiFlags
DE), and an emoji tag sequence over U+1F3F4 WAVING BLACK FLAG encodes an ISO 3166-2
subdivision code in tag characters (the England flag decodes to GB-ENG); both mechanisms
are defined by UTS #51.
Decoding is mechanical and deliberately does not check assignment: U+1F1FD U+1F1FD
decodes to XX even though no such region is assigned, because validity against the
region registry is a join-time question for whatever gazetteer the user has installed (see the
joined-facts layer), not a bundled fact. This is also why no per-flag rows exist in
emoji-annotations.txt: the region code is fully determined by the sequence itself.
isoRegion(CharSequence) is the strict decoder: it fails loud on a sequence that is
flag-shaped but malformed, such as a lone regional indicator or an unterminated tag sequence.
isFlag(CharSequence) is the total predicate for bulk callers that must never throw on
degenerate real-world text. The expected input is one symbol, for example one
Term.original() token; the UAX #29 word tokenizer already segments a run of
adjacent flags into regional indicator pairs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisFlag(CharSequence symbol) Returns whethersymbolis exactly one well-formed flag emoji.isoRegion(CharSequence symbol) Decodes one flag emoji to its ISO 3166 code: a regional indicator pair to the ISO 3166-1 alpha-2 code (DE) and a subdivision tag sequence to the ISO 3166-2 code (GB-ENG).
-
Method Details
-
isFlag
Returns whethersymbolis exactly one well-formed flag emoji. True only for a regional indicator pair or a terminated subdivision tag sequence; unlikeisoRegion(CharSequence)this never throws on malformed sequences, so bulk callers (per-token annotation of arbitrary text) can probe safely.- Parameters:
symbol- The code point sequence of one symbol. Must not benull.- Returns:
- whether
symbolis exactly one well-formed flag emoji - Throws:
IllegalArgumentException- ifsymbolisnull.
-
isoRegion
Decodes one flag emoji to its ISO 3166 code: a regional indicator pair to the ISO 3166-1 alpha-2 code (DE) and a subdivision tag sequence to the ISO 3166-2 code (GB-ENG).- Parameters:
symbol- The code point sequence of one symbol. Must not benull.- Returns:
- The ISO 3166 code, or empty when
symbolis not flag-shaped at all (no leading regional indicator and no tag sequence over U+1F3F4; a lone U+1F3F4 and the ZWJ pirate flag are not region flags). - Throws:
IllegalArgumentException- ifsymbolisnull, or if it is flag-shaped but malformed: a lone regional indicator, more or fewer than exactly two regional indicators, or a tag sequence that is unterminated, too short for a subdivision code, not letter-led, or followed by trailing content.
-