Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get country code from number prefix with international dialing prefix(IDD) #79

Closed
iammehrabalam opened this issue Jun 19, 2016 · 1 comment
Labels

Comments

@iammehrabalam
Copy link

Is it possible to get the country code from number prefix with international dialing prefix(IDD)?
Note: I don't know country from which number belongs to.

example: 009654835665

00 --> international dialing prefix

@daviddrysdale
Copy link
Owner

If you know the country that the number is dialled from, then parsing relative to that country should work:

>>> x = phonenumbers.parse("009654835665", "GB")
>>> x.country_code
965
>>> phonenumbers.region_codes_for_country_code(x.country_code)
('KW',)

If you don't know where the number is dialled from, there's more of a problem because the digit sequences aren't globally unique, i.e. the same sequence connects to different results depending on where you dial it from.

(If you knew for sure that the international dialing prefix was 00, then you might be able to replace the 00 with + and parse the number as an E.164 number -- but that's basically the same thing: to be sure the international dialling prefix was 00, you'd have to know the country that the number was dialled from).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants