14 lines
353 B
Rust
14 lines
353 B
Rust
pub fn country_code_to_flag(code: &str) -> String {
|
|
if code.len() != 2 {
|
|
return "🏳".to_string();
|
|
}
|
|
|
|
code.to_uppercase()
|
|
.chars()
|
|
.map(|c| {
|
|
// regional indicator symbols start at 0x1F1E6 ('A')
|
|
char::from_u32(0x1F1E6 + (c as u32 - 'A' as u32)).unwrap_or('?')
|
|
})
|
|
.collect()
|
|
}
|