mledoze / countries

World countries in JSON, CSV, XML and Yaml. Any help is welcome!
https://mledoze.github.io/countries/
Open Data Commons Open Database License v1.0
5.97k stars 1.27k forks source link

Countries with multiple calling codes #114

Closed NathanHazout closed 1 year ago

NathanHazout commented 9 years ago

Because my application logic has a hard time with the concept of a country with multiple country codes, I decided to take a look:

Kazakhstan Kosovo Puerto Rico Vatican City Dominican Republic

For all of them, a google search told me there was only 1 country code. Often, it seems you include some of the regional codes as part of the calling code...

Also, I randomly looked at Dominica which returns ["1767"] but according to Google is simply +1.

mledoze commented 9 years ago

For all of them, a google search told me there was only 1 country code.

Could you please provide a source for this? I couldn't find any.

NathanHazout commented 9 years ago

http://en.wikipedia.org/wiki/Telephone_numbers_in_Kazakhstan

http://en.wikipedia.org/wiki/Telephone_numbers_in_Kosovo

Actually in Google just type "[country name] country code" and you will see a big square with the flag and the country code.

Here is another source: http://countrycode.org/puertorico

http://countrycode.org/country_detail.cfm?countryid=104

I think that part of the problem is that some countries use the same country code as others, and use a subset. For example, while +1 is usually associated with the U.S., it really is the dialing number for NANPA (http://en.wikipedia.org/wiki/North_American_Numbering_Plan) which includes 25 countries. In your database, for those countries you added the local area code(s) to make it more specific.

I only gave the example of NANPA (and Vatican, which uses a sub-area of Italy's 39), however I'm sure many countries have similar issues.

Here is an interesting link as well: http://en.wikipedia.org/wiki/List_of_country_calling_codes

yackermann commented 9 years ago

@nasht00 Thanks for the answer. That explained a lot. @mledoze I will take care of implementation. Give me couple of days.

mledoze commented 9 years ago

@nasht00 yes calling codes include local area codes. These codes are for making an international call.

I think that part of the problem is that some countries use the same country code as others

Yes, this is true for Canada the United States, for example. But why is this a problem for your application?

NathanHazout commented 9 years ago

I don't mean Canada and the US. Like mentioned before, like the 25 countries that share "+1", but where most of those 25 countries are not listed as "+1" in this database.

I don't mean a problem for my application, I mean a problem in defining the country code for each country. I mean the source of the confusion.

You wrote "yes calling codes include local area codes." But that's not so obvious. To call someone in the Dominican Republic let's say his number is +1 809 777 7777. I could say the dialing code is "+1" and the number is 8097777777 or I could say the calling code is "+1809" and the number is 7777777. That would be fine if Dominican Republic only used 1809, but since they also use 1829 and 1849, it becomes confusing.

In my application, I have a dropdown when the user selects his country. It shows "CountryName (+code)". For example "France (+33)". And next to the dropdown is a text input to enter their local phone.

You can see how it can get confusing in the case of Dominican Republic where there are 3 possibilities. In my application, I made it so that it shows "Dominican Republic (+1)".

To be honest I am not completely sure what the correct implementation should be... But multiple calling codes can be confusing. Maybe it needs a new field. One field would have the full list you have now, and one field would only hold the common denominator (+1 in this example).

Just a thought...

petert82 commented 9 years ago

yes calling codes include local area codes. These codes are for making an international call.

Maybe I'm being slow, but I don't quite understand this. If it's the international dialling code, why does it ever need a local part?

I'm almost certain that the dataset would be more correct if all countries only had one international dialling code, and the countries that have extra 'local' digits included currently (like Dominica) were reduced to just the international code.

And if we want to correct this, it wouldn't be too hard to whip up a script using libphonenumber to auto generate the calling codes.

mledoze commented 9 years ago

@nasht00, @petert82 thank you for your explanations, I think you are right on this, I'm ok to have only one calling code per country, it makes more sense now.

@herrniemand

I will take care of implementation. Give me couple of days.

You proposed to fix this, would you like some help?

yackermann commented 9 years ago

@mledoze Nah. Its just couple of python scripts. I will finish it by Friday.*)

mledoze commented 1 year ago

Already done, see #124 and then #326