Search code examples
sqltelephony

Country calling codes including area codes


I'm trying to create a table full of calling country codes, so I can match phone numbers and retrieve their country of origin.

I'm aware of http://blog.attigohk.com/2010/12/12/countriesdb-free-country-code-sql-database/ and especially http://www.itu.int/ which contains the "official" list.

But I'm stuck on getting area codes as well, as Canada and USA share +1, so that's no good identifying a number only with +1.

Can anyone help me in the right direction, so "all the worlds" phone'numbers can be identified?


Solution

  • I would use Wikipedia's lists here. For +1 you're going to have to use more digits to identify the country as it is also shared by various Caribbean nations. This other Wikipedia article breaks it down here.

    It may also be useful to have the list of international prefixes too (that is, the digits used to indicate you are dialing internationally). That list is here. That can be handy in some environments where you can't be sure the format of the phone number provided to you. For example, some mobile carriers will send usage records with the number as dialled by the customer such as '+441234567890' as that is automatically converted to '0011441234567890' but some customers will dial that full number so you'll need to know which numbers to ignore.