pub fn country_flag(country_code: &str) -> String
Available on crate feature alloc only.
Expand description

Generate an ad-hoc country flag.

This function allows to create arbitrary country flags.

The Unicode standard defines country flags based on the two-letter country codes (see ISO 3166-1 alpha-2). Notice most (if not all) fonts support only the defined codes, however, this function does not test whether the given code is in deed a well defined country code.

Panics

If the provided string contains characters other than exactly two ASCII letters (A-Z).

Examples

use emojic::country_flag;

assert_eq!(
    country_flag("EU"), // 🇪🇺
    emojic::flat::FLAG_EUROPEAN_UNION.to_string()
);

But there is no validity test:

use emojic::country_flag;

println!("{}",
    country_flag("ZZ"), // 🇿🇿 (an invalid flag)
);