Obtain Iso 3166-1 alpha-2

363 views
Skip to first unread message

Johan Jourdan

unread,
Jul 22, 2020, 5:09:08 AM7/22/20
to libphonenumber-discuss
Hi,

Is there a way to obtain the iso 3166-1 alpha-2 (if not,  the country name ?) from a country code ?
I easily obtain the country code but i need to determine the country, is it possible with this lib ?

Thank,

Johan

David Beaumont

unread,
Jul 22, 2020, 5:17:19 AM7/22/20
to libphonenum...@googlegroups.com

Pass in the complete number rather than using just the calling code (since calling codes are shared between regions such as US/CA/PR etc.).
If you only have a country calling code, you will sometimes get ambiguous results.

Also note that libphonenumber does not use ISO 3166-1 alpha-2, it uses BCP-47 for region codes. This distinction mostly doesn't matter except for deprecated regions (e.g. "CS" was reused in ISO, but BCP-47 never reuses region identifiers).

HTH,
   David

--
You received this message because you are subscribed to the Google Groups "libphonenumber-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libphonenumber-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libphonenumber-discuss/a1605354-4c00-489e-a3fa-0398fc8d6ddcn%40googlegroups.com.


--
David Beaumont :: Îñţérñåţîöñåļîžåţîờñ Libraries :: Google
Google Switzerland GmbH., Brandschenkestrasse 110, CH-8002, Zürich - Switzerland

Johan Jourdan

unread,
Jul 22, 2020, 5:44:44 AM7/22/20
to libphonenumber-discuss
Thank for your very quick answer,

That's what i needed, now it work perfectly thank 

Reply all
Reply to author
Forward
0 new messages