Get list of country name and country code

5,373 views
Skip to first unread message

Ann

unread,
May 30, 2013, 8:51:16 PM5/30/13
to libphonenum...@googlegroups.com
Hi all, 

I plan to have a mapping list of countryName - countryCode. Such as, United State (+1), United Kingdom (+44) .

I know that libphonenumber is a great tool to help phone parsing, formatting and validation. However, it doesn't seem to have the functionality for listing the mapping country names/codes. But those data should be within the metadata in libphonenumber, right? Does anyone have experience on this?

Thanks!

Lara Rennie

unread,
May 31, 2013, 3:47:03 AM5/31/13
to libphonenum...@googlegroups.com
You need:
* getSupportedRegions() to get the list of region codes
* getCountryCodeForRegion(regionCode) to get the country calling code for each one (1, 44 etc)

And then to get the actual names, you should use ICU4J -> http://icu-project.org/apiref/icu4j/ --> it will get you country names from these region codes in whatever language your user speaks. (getDisplayCountry())

What are you planning on doing for non-countries, e.g. +800? Do you want to support those? Because we don't have names for those, but you can get the calling codes with getSupportedGlobalNetworkCallingCodes.


2013/5/31 Ann <ann...@gmail.com>

--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages