dr5hn / countries-states-cities-database

🌍 Discover our global repository of countries, states, and cities! 🏙️ Get comprehensive data in JSON, SQL, PSQL, XML, YAML, and CSV formats. Access ISO2, ISO3 codes, country code, capital, native language, timezones (for countries), and more. #countries #states #cities
https://dr5hn.github.io/countries-states-cities-database/
Open Data Commons Open Database License v1.0
6.81k stars 2.44k forks source link

Flag issue #786

Open amanpoplify opened 2 weeks ago

amanpoplify commented 2 weeks ago

Flags are not showing in windows. Can someone please have a look.

dosubot[bot] commented 2 weeks ago

Hey @amanpoplify! 👋 I'm here to help you out with any issues you're facing. I'm a bot designed to assist with bug fixes, answer questions, and guide you on becoming a contributor. Let's squash those bugs together!

The flags in the countries-states-cities-database repository are provided in the emoji format [1]. There was a similar issue reported where flags were not displaying correctly in new browser versions, which might be related to your problem. You can check the details here [2].

To continue talking to Dosu, mention @dosu.

amanpoplify commented 2 weeks ago

@dosu this is the error I am facing

Screenshot 2024-06-12 at 2 27 19 PM
dosubot[bot] commented 2 weeks ago

The issue with flags not showing in Windows when using emoji format might be related to the support for emoji flags in the specific environment or application you are using. Emoji flags are represented by combining two regional indicator symbols, which are supported in most modern operating systems and browsers. However, some environments might not fully support these emoji flags.

To resolve this issue, you can try the following steps:

  1. Update Your Operating System and Browser: Ensure that you are using the latest version of your operating system and browser, as updates often include improved support for emojis.

  2. Check Font Support: Make sure that the font you are using supports emoji flags. Some fonts might not include the necessary glyphs for displaying emoji flags. You can try using a font known for good emoji support, such as "Segoe UI Emoji" on Windows.

  3. Use Alternative Representation: If emoji flags are not essential, consider using alternative representations such as image files of flags or text-based country codes.

  4. Test in Different Environments: Test the display of emoji flags in different environments (e.g., different browsers, text editors, or applications) to identify if the issue is specific to a particular environment.

Here is an example of how you might include emoji flags in HTML, ensuring that the font is set to one that supports emojis:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Emoji Flags</title>
    <style>
        body {
            font-family: 'Segoe UI Emoji', sans-serif;
        }
    </style>
</head>
<body>
    <p>Afghanistan: 🇦🇫</p>
    <p>Aland Islands: 🇦🇽</p>
    <p>Albania: 🇦🇱</p>
    <p>Algeria: 🇩🇿</p>
    <!-- Add more countries as needed -->
</body>
</html>

If the issue persists despite these steps, it might be a limitation of the specific environment or application you are using, and you may need to consider alternative methods for displaying flags.

Additionally, you can refer to the countries-states-cities-database repository for the correct emoji representations of country flags. For example, the JSON data for Afghanistan includes the emoji "🇦🇫" and its Unicode representation "U+1F1E6 U+1F1EB". This information can help ensure that you are using the correct emoji codes.

In the countries-states-cities-database repository, the flags are included in the JSON data and displayed using JavaScript. Here is a snippet from the repository that shows how the flags are used:

const countriesJSON = 'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/countries.json';

async function initializeData() {
  var countries = db.getCollection("countries");
  if (!countries) {
    countries = db.addCollection('countries');
    await fetch(countriesJSON)
      .then(response => response.json())
      .then(async (data) => {
        await data.forEach((c) => {
          countries.insert(c);
          $('.countries-tb').append(`
            <tr>
              <td class="border px-4 py-2">
                ${c.emoji} ${c.name}  <span class="inline-block bg-gray-200 rounded-full px-3 text-sm font-semibold text-gray-700">${c.iso2}</span> <button class="tooltip inline-block align-middle float-right" onclick="filterStates(${c.id})"><svg viewBox="0 0 20 20" fill="currentColor" class="arrow-circle-right w-6 h-6 text-pink-600"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-8.707l-3-3a1 1 0 00-1.414 1.414L10.586 9H7a1 1 0 100 2h3.586l-1.293 1.293a1 1 0 101.414 1.414l3-3a1 1 0 000-1.414z" clip-rule="evenodd"></path></svg><span class="tooltip-text bg-indigo-600 rounded text-white text-sm -mt-12">Show States</span></button> <button class="tooltip inline-block align-middle float-right" onclick="toggleModal(${c.id}, 'countries')"><svg viewBox="0 0 20 20" fill="currentColor" class="information-circle w-6 h-6 text-blue-600"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd"></path></svg><span class="tooltip-text bg-indigo-600 rounded text-white text-sm -mt-12">More Details</span></button>
              </td>
            </tr>
          `);
        });
      });
  }
}

initializeData();

This code fetches the country data, including the emoji flags, and appends it to the HTML table. Make sure your environment supports the necessary fonts and that you are using the correct emoji codes from the repository [1][2][3].

To continue talking to Dosu, mention @dosu.