RepositoryJavaScriptUSHoa Kỳ
thekelvinliu

thekelvinliu/country-code-emoji

convert country codes (ISO 3166-1 alpha-2) to corresponding emoji flags (unicode regional indicator symbols)

142sao
11fork
2issue
1lượt xem

🇺🇸 Chuyển mã quốc gia thành emoji cờ lá cờ bằng JavaScript

Thư viện không phụ thuộc, hỗ trợ cả CommonJS và ES module, dùng String.fromCodePoint nội bộ.

country-code-emoji là một module JavaScript nhỏ gọn, không phụ thuộc bên ngoài, chuyển đổi mã quốc gia dạng ISO 3166-1 alpha-2 (ví dụ: "US") sang emoji cờ tương ứng (ví dụ: "🇺🇸") và ngược lại. Dự án hỗ trợ cả định dạng CommonJS và ES module thông qua package.json.

✨ Điểm nổi bật

  • Chuyển đổi hai chiều: hỗ trợ cả countryCodeEmoji(cc) và emojiCountryCode(flag).
  • Không phụ thuộc: toàn bộ logic nằm trong thư viện, không cần gói bổ sung.
  • Hỗ trợ môi trường hiện đại: dùng String.fromCodePoint, không cung cấp polyfill.
  • Xử lý lỗi rõ ràng: ném TypeError nếu đầu vào không hợp lệ.
  • Không phân biệt chữ hoa/thường: chấp nhận "us", "US", "Us" đều trả về cùng một kết quả.
  • Tương thích kép: cung cấp build CommonJS và ES module.

💡 Vì sao đáng chú ý

Không cần dùng thư viện nặng để hiển thị cờ quốc gia, chỉ cần một hàm nhỏ là đủ. Đặc biệt hữu ích khi cần hiển thị danh sách quốc gia dưới dạng emoji trong giao diện người dùng, form chọn quốc gia, hoặc bảng dữ liệu quốc tế.


#JavaScript #Emoji #CountryCode #ISO3166 #TiniX

Dự án tương tự

Khám phá các dự án và mô hình AI khác có sự tương đồng.

RepositoryPython
cvzi/flag

Flag emoji from country codes for Python 🏳️‍🌈🌍

67
Nov 11, 2026
RepositoryPHP
raramuridesign/mysql-country-list

mysql insert country list into database

479
Nov 1, 2026
RepositoryPHP
lwwcas/laravel-countries

Laravel country database package with Eloquent models, ISO 3166 codes, country flags, GeoJSON maps, phone codes, currencies and translations in 9 languages. Built with migrations & seeders for Laravel 10–13.

132
Jul 16, 2026
RepositoryJava
blongho/worldCountryData

Android library for country flag, currency, and other country information

102
Oct 14, 2026
RepositoryRuby
sshaw/normalize_country

Convert country names and codes to a standard.

70
Feb 22, 2025
Repository
tuannvbg/unicode-flags-for-windows

Fix flag emoji for Windows 10/11: show full‑color country flags 🇻🇳 🇺🇸 🇯🇵 instead of VN/US/JP two‑letter codes. Unicode 17.0 & 18.0 + Noto Color Emoji 18.0 (2D ready, 3D coming soon). No waiting. Just fix it.

70
Nov 24, 2026
RepositoryTypeScript
necessarylion/country-list-with-dial-code-and-flag

Country Flag with Dial Number Code

63
Oct 28, 2026
RepositoryJavaScript
carloscuesta/gitmoji-cli

A gitmoji interactive cli tool for using emojis on commits. 💻

4.8k
Dec 1, 2026
RepositoryJavaScript
mathiasbynens/emoji-regex

A regular expression to match all Emoji-only symbols as per the Unicode Standard.

1.9k
Sep 15, 2026