I would like to find a tool/library that can take user-entered free format telephone numbers entered through a web site and parse them into a number suitable for calling from a given country.
This is not quite as simple as it may at first sound. The website allows people all around the world to enter their number in any way they choose, so many people enter national numbers (a country is also provided in another field). Some people enter the international number in “correct” formats (with the “+”), some people enter it slightly less correctly, using their country’s international prefix.
I would like to tell the library/tool the country that I’m dialling from, and the free-format telephone number and optionally the country that this corresponds to (as this will help generate the international code if not entered), and it use known patterns to best-guess the number that will work in my calling country
So, for example, when calling from the US to a UK number:
+44 (0) 1225-344567 => 011441225344567
Or when calling from the UK to a US number:
(613) 4562342 => 0016134562342
Anyone know of any (ideally .NET Framework-friendly) solutions that will avoid me undoubtedly re-inventing the wheel
Yes: Google’s common Java, C++ and Javascript library for parsing, formatting, storing and validating international phone numbers has now been ported to C#:
https://github.com/erezak/libphonenumber-csharp
Good Luck!