Reputation: 17
I tried parsing a string containing phone number but with zero as prefix before international country code using libphonenumber library, it is giving exception :
"INVALID_COUNTRY_CODE. Could not interpret numbers after plus-sign."
and how to make it work only for two characters of zero before country code or after country but it should fail if it has more that 2 characters of zero.
Upvotes: -2
Views: 434
Reputation: 1069
The prefix 00
is not in all countries the 'official' prefix for the country code. And therefore the library does not by default accepts it.
You can test the library on that web page: http://libphonenumber.appspot.com/
You will see that your number is only accepted, when you select a default country that uses 00
as country code prefix. You can test it by setting gb
in the Default Country field.
The documentation of the library you can find on that web page
As you can see the second argument of the parse
method is the defaultRegion. You must set a country that uses the phone number format that you want to parse.
This answers the second part of your question. As you will see the first part of your question has the same solution.
Upvotes: 2