#flags #emoji #country #localization #bcp47 #iso-3166-1

country-emoji

Converts between country names, ISO 3166-1 codes and flag emojis

4 releases

0.2.0 Nov 27, 2021
0.1.2 Oct 26, 2020
0.1.1 Oct 26, 2020
0.1.0 Oct 26, 2020

#124 in Internationalization (i18n)

Download history 30/week @ 2024-01-01 49/week @ 2024-01-08 100/week @ 2024-01-15 5/week @ 2024-01-22 16/week @ 2024-01-29 30/week @ 2024-02-05 24/week @ 2024-02-12 30/week @ 2024-02-19 60/week @ 2024-02-26 96/week @ 2024-03-04 76/week @ 2024-03-11 36/week @ 2024-03-18 22/week @ 2024-03-25 116/week @ 2024-04-01 36/week @ 2024-04-08 27/week @ 2024-04-15

204 downloads per month

MIT license

24KB
375 lines

country-emoji

crate.io

Converts between country names, ISO 3166-1 codes and flag emojis.

Usage

use country_emoji::{flag, code, name, countries};

flag("CL")
 // ~> ๐Ÿ‡จ๐Ÿ‡ฑ

code("๐Ÿ‡จ๐Ÿ‡ฆ")
 // ~> CA

name("๐Ÿ‡ถ๐Ÿ‡ฆ")
 // ~> Qatar

// can extract name from stringโ€ฆ
flag("Taiwan number one!")
 // ~> ๐Ÿ‡น๐Ÿ‡ผ

// โ€ฆbut only if there"s no ambiguity
flag("Congo and Burma")
 // ~> undefined

flag("Republic of Tanzania")
 // ~> ๐Ÿ‡น๐Ÿ‡ฟ

flag("Tanzania, United Republic of")
 // ~> ๐Ÿ‡น๐Ÿ‡ฟ

code("Australia")
 // ~> AU

code("UAE")
 // ~> AE

name("AE")
 // ~> United Arab Emirates

code("UK")
 // ~> GB

Don't want Rust?

Check out the following:

Bugs and feedback

If you discover a bug please report it here. Express gratitude here.

Mail me at leodutra.br+foss@gmail.com, or on twitter @leodutra.

Credits

This library is based on the work of two existing library:

Thanks guys for your work!

License

MIT @ Leo Dutra

Dependencies

~2.1โ€“3MB
~53K SLoC