Is there a centralized list of country names that

2019-01-21 23:16发布

问题:

There are examples online with web select boxes that have a huge list of countries and that probably will be good enough for me to use. However, by Murphy's law, there's bound to be some random country that someone is from and isn't on my list (and probably someone else also ran into this and has updated their local list). Also, when new countries are added, I won't know about it.

Basically, I feel it's better practice and a better smell if there is some centralized list of country names that I can use / trust. (also it could set/follow standards for exact namings "United St..." vs "USA" etc.)

I would prefer a solution that isn't IIS specific if possible

回答1:

There are many list of countries, check this wikipedia article; there you can find some lists like:

  • ISO 3166-1 countries codes
  • IOC country codes
  • Alternative country names

And more...



回答2:

We maintain a list of 'PUBLIC DOMAIN' Worldwide Country names in all official formats. The information comes from the ISO 3166-1 Maintenance Agency for offical English and French short names, the US Board on Geographic Names (BGN) for english short, long and local short, long names, and United Nations Group of Experts on Geographic Names (UNGEGN) format (long) English, French names, short and formal local names and Spanish names.

There still is a problem representing some Arabic characters as romanized characters (will see ?). But these are limited to the local names of a few Arab countries.

Note, the English, Spanish and French cover the 3 Western languages of the UN's official 6 languages. Metadata, information on the sources, and download can be found at:

http://www.opengeocode.org/download.php#countrynames

The Open Geocode Team OpenGeoCode.org

Jan. 26, 2014. We updated the list to include country names in Italian and German. We used the UN Food & Agriculture list of countries in Italian and the German Government's Federal Foreign Office's list of countries in German.



回答3:

An answer to this question contains a useful link to a Github project that has lists in various formats and the script that produced them, making it easy to obtain updated versions.



回答4:

No list is comprehensive.

"there's bound to be some random country that someone is from and isn't on my list"

If that was all there was to it, it would be simple.

There's no "world law" or "world constitution", so there's no single list of countries, republics, territories, protectorates, autonomous regions, independent governments, and disputed territories.

Indeed, it's not possible to come to an agreed-upon definition of "country" which would lead to a final list of country codes. The definition of "country" is politically charged. What, for example, is Tibet? Country or region of China? Northern Ireland? The Holy See?

Pick a list, and know that it's subject to some dispute.

You could, for example, use the IANA country code database: http://www.iana.org/domains/root/db/

It's as good as any, and since it's part of the IANA, it has some standing as a standard. Further, it's pretty accessible as easy-to-parse web content.



回答5:

I have a recent list ready to go on my website at http://www.john.geek.nz/index.php/2009/01/sql-tips-list-of-countries/

It's both at sql and tab delimited - The original list was sourced from wikipedia



回答6:

I recommend pulling data out of the Unicode CLDR (Common Locale Data Repository), which include a professionally-maintained list of countries and country name data.

Grab the data from there once, and do updates once in a while; the CLDR data will come in a consistent format, so you won't need to fuss over it once it's part of your workflow.



回答7:

I don't know what IIS is, but ISO 3166 specifies 2-letter codes for each country; AFAIK, their list is comprehensive. ISO 3166 site



回答8:

This is probably way too late, but there's a web service that you can call that would theoretically allow you to automatically databind your controls: http://www.webservicex.net/country.asmx

May give you another approach and would be better than hard-coding a list yourself.



回答9:

I've posted a few files to github:gist

Including:

The HTML Select enumerations for the Alpha-2, Alpha-3, and Numeric-3 values, as well as an XSD snippet of those values as enumerations for a simple type restriction.

Check on this link



回答10:

The CIA world fact book has this information, however, just as you point out in your question there are some disputed countries that are not on their list sometimes, ie. Palestine.

Another source for country names is Natural Earth Data and their cultural map download links which come as shape files ready to be plotted as maps. Here is a direct link to the medium quality map data download page.



回答11:

Check out angrymonkeycloud.com/geography to get the full list of countries.

It's a free .Net client and so easy to start with, and it uses an API to retrieve values so you should always get the latest updates.



回答12:

Much, much easier is to use a web service for this task rather than holding your own data store. This way its updated and you can do things like have country-state ajax dropdown sets. http://geodata.solutions is the best one to use, and it has lots of cools stuff like being able to pre-select the user's country based on their IP, and ordering lists by their population.