views:

143

answers:

2

Does anyone know of a generic phone number parsing library for .NET? Ideally I'm looking for something similiar to the Ruby Phone library.

+1  A: 

You could start with Advanced Phone Number Type Implementation on CodeProject. At first glance, it seems that it may be lacking the internationalization pieces found in the Ruby library you referenced.

Of course, you could always start with an existing library and add on to it, and depending on the license of the original library, you might even choose to release your own that has exactly what you need.

Ben McCormack
Good find; this looks promising!
DanP
While this does seem like a good starting point, international number support is a likely requirement here; if anyone has any additional suggestions - I'd be very interested.
DanP
@DanP apparently you're not the only one looking to solve this problem. Take a look at: http://stackoverflow.com/questions/501368/phone-number-format-and-validation-library .
Ben McCormack
@Ben: Yes, rather strange something doesn't exist for this...it would *seem* to be a pretty common requirement in a number of projects.
DanP
@DanP I think the problem you're going to face (and perhaps the reason the library likely doesn't already exist), is that phone-number parsing is a moving target, especially when it comes to internationalization. You would think it would always be the same, but if you want to get really specific, there are lots of pesky little details for each country that could shift at whim. If I were writing the library, I would start with a base template that could handle simple country codes and possibly expand to add validation for specific country codes that I anticipated using.
Ben McCormack
@BeN: agreed, I will accept this answer as the 'closest' one I've recieved; this should serve as a decent starting point - thanks for your feedback on this.
DanP
A: 

Have you considered taking the Ruby library you referenced and porting it to IronRuby, which runs on the .NET DLR? I haven't used IronRuby before, but since it's a .NET language, you may be able to simply port the code over and expose and strongly-typed interface that can be better consumed in VB.NET or C#.

Ben McCormack
@BeN: I had considered this option as well - just seems like a bit of an overkill for phone number parsing.
DanP