Unicode Country Flags

No image, no CSS, you can show country flags on your web pages with unicode only. See Regional Indicator Symbol for details. And find valid country codes here, ISO 3166-1 alpha-2.

Installation

Add this line to your application's Gemfile:

gem 'unicode_country_flags'

And then execute:

$ bundle

Or install it yourself as:

$ gem install unicode_country_flags

Usage

Get the raw code:

UnicodeCountryFlags.flag_of('cn')  #=> "🇨🇳"

Or use the helper, unicode_country_flag_of, in view code:

<% %w{ US GB AU CN JP }.each do |code| -%>
  <span><%= unicode_country_flag_of(code) %> <%= code %></span>
<% end %>

🇺🇸 US 🇬🇧 GB 🇦🇺 AU 🇨🇳 CN 🇯🇵 JP

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/YanhaoYang/unicode_country_flags.