Obviously no country code can be a prefix of another one. The switches would not know how to interpret it.
But 2 or more countries can use the same country code. The area code will determine which country you call to.
In the North American numbering plan +1 all numbers must have a fixed length 3 + 3 + 4.
In many other numbering plans the length varies. Both area code length and subscriber number length can vary. So it gets pretty complicated to parse a number. Basically rules don't help, you need a database and you need to update it regularly. No idea whether an open, non-commercial data set exists.
When I call to Germany Android shows the name of pretty small places. I believe Android reports every number you call to Google. But the database is probably still local, I believe locations are also shown when you have no data connection.
I am not from the US, but I understood there you might also need extensions to be dialled after the number proper.
But 2 or more countries can use the same country code. The area code will determine which country you call to.
In the North American numbering plan +1 all numbers must have a fixed length 3 + 3 + 4.
In many other numbering plans the length varies. Both area code length and subscriber number length can vary. So it gets pretty complicated to parse a number. Basically rules don't help, you need a database and you need to update it regularly. No idea whether an open, non-commercial data set exists.
When I call to Germany Android shows the name of pretty small places. I believe Android reports every number you call to Google. But the database is probably still local, I believe locations are also shown when you have no data connection.
I am not from the US, but I understood there you might also need extensions to be dialled after the number proper.