4

I'm using the below link:

http://libphonenumber.googlecode.com/svn/trunk/javascript/i18n/phonenumbers/demo-compiled.html
  • phone number: 96596032346
  • region code: KW

the link returns that the number is valid.

I'm using the library in C# as below :

 PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
 phoneNumber = PhoneNumberUtil.Normalize(phoneNumber);
 PhoneNumber nb = phoneUtil.Parse(phoneNumber, regionCode);
 bool isValid = phoneUtil.IsValidNumber(nb);

I'm passing the same parameters phoneNumber=96596032346 and regionCode=KW but it's returning is that the number is not valid.

I checked for some updates for the library but I have the latest version. What could be the problem?

user247702
  • 23,641
  • 15
  • 110
  • 157

2 Answers2

0

Interesting library.

The website gives an example of how to parse/normalize a phone number from Switzerland, but does not show where they call Normalize anywhere in their example.

String swissNumberStr = "044 668 18 00"
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
  PhoneNumber swissNumberProto = phoneUtil.parse(swissNumberStr, "CH");
} catch (NumberParseException e) {
  System.err.println("NumberParseException was thrown: " + e.toString());
}

Are you sure you are supposed to be calling Normalize in your code?

0

i found that there is a version 5.8 for c# but this version is not updated in the nuget packages, so i downloaded the dll file and implemented it in the project...

worked great :)