

Google's library for dealing with phone numbers (Java/JavaScript) - kondro
http://code.google.com/p/libphonenumber/

======
jokermatt999
Somewhat unrelated, but I've grown to dislike the Skype addon for Firefox
because of its phone number recognition. It gets far too many false positives.
Even numbers several digits short of being a phone number are often mistaken
as one, throwing off the formatting of the page.

~~~
haribilalic
It's worse on the iPhone! It's hard to tell if a number is a genuine hyperlink
or something the iPhone has recognised as a phone number.

~~~
jonknee
Just tap and hold, you'll see which in about a second.

~~~
haribilalic
I know, but I'm lazy and I'd like to be able to know by looking at a link
instead of tapping and holding each number for a few seconds (and then
pressing the cancel button if it's a phone number).

~~~
jonknee
Apple could put a little phone icon to the left or right of the auto-generated
links. In my usage though phone numbers are very rarely linked (where would
they go?), so when I see a linked one on an iOS device I assume it will
trigger a phone call.

------
eneveu
Now I feel bad for not posting it here as well (I posted it on reddit a few
days ago:
[http://www.reddit.com/r/java/comments/et5az/libphonenumber_g...](http://www.reddit.com/r/java/comments/et5az/libphonenumber_googles_common_java_library_for/)
) :(

I often avoid posting java links to HN, thinking that the HN community is more
focused on Rails / node.js / python. Guess I should reconsider :)

Funny how this intangible karma stuff affects me :)

~~~
kondro
And I regret not blogging about it on my personal blog and linking that here
to generate traffic and potential subscribers there. LOL.

Of course, it may not have actually been a wasted opportunity as the
(google.com) URL part of the title probably accounts for a large percentage of
clicks.

P.S. I upvoted your comment to generate a little more karma as compensation.

~~~
eneveu
Hehe. Not sure you should do that though (according to the HN guidelines, one
should submit the original source) ;)

Thanks for the upvote, that's kind of you!

In retrospect, I shouldn't have "whined" in my previous comment. As the
Facebook quote goes ("If you guys were the inventors of Facebook, you'd have
invented Facebook"): had I wanted to post this on HN, I would have posted it
on HN!

I'll try to post more links in the future (Java or otherwise), and stop trying
to anticipate their success according to some pre-conceived notion of what the
HN crowd likes: if I think it is interesting, someone else might like it as
well ;)

------
kondro
Found this today whilst I was looking for a solution to standardised
formatting of phone numbers. I was hoping for a ruby solution, but this is an
extremely complete library supporting formatting and validation for 228
countries/regions.

~~~
davidradcliffe
How much work would it take to make a complete ruby port?

~~~
kondro
Well... habermann24 (<https://github.com/habermann24/libphonenumber-ruby>)
looks like he's started on a ruby port and he also has his phoney library
which doesn't appear to use the same dataset and doesn't work properly for
Australia.

I am planning on just using the Java version with JRuby - it will probably be
faster than a pure ruby version anyway.

------
damncabbage
I've looked around and haven't found a PHP port of this.

Given the usefulness of this library, I've been inspired to give it a go:
<http://github.com/damncabbage/libphonenumber-php>

(Java --> PHP is tough going. Come back in a month. ;) )

------
bluedevil2k
This would be good for Twilio, which doesn't have any phone number validation
methods in its libraries.

~~~
ceejayoz
That always struck me as an odd omission.

~~~
kondro
Well, when you think about the amount of data collection required to reach
this level of coverage I don't blame a smallish start-up like Twilio for not
having a library.

After all, if you want to test to see if a number is valid, try and call it.

~~~
chronomex
It's a daunting amount to approach, but it rarely takes more than an hour or
two per country. I've been doing something similar for my current project,
because I want to take phone numbers in national form and show them in both
international and national forms.

~~~
mickeyben
So if you need to handle the 228 countries this lib handle, you _only_ need
228 to 556 hours of work ...

~~~
chronomex
Well, given that I'm taking longer than that to collect my data for each
country, it seems like a bargain!

~~~
g1smd
This stuff is non-trivial. I'll guess that I have spent in excess of 50 hours
working on just the UK data in the last couple of months.

The problem is this. Although there are hundreds of websites with UK area code
lists, almost all of them are either incorrect, out of date, full of typos, or
are generally unreliable. Even lists from "official" sources cannot be relied
on with any degree of certainty. The obvious errors are easy to find and
correct. It took a long time to find out there were many non-obvious errors
and there are likely more errors still to be uncovered.

------
pilif
Fun fact: The swiss phone number they use in the example apparently is the
phone number of Google's Swiss Office in Zürich.

------
ramki
I have been looking for similar lib in C\C++.

------
chronomex
Awesome! I'm currently working on a project to deal with all sorts of phone
numbers in bulk. I've already duplicated some of this in my own way, but I
think it might come in handy for the rest.

------
coverband
This is pretty cool -- how do they deal with changes to the metadata, like
when a country has a new code?

~~~
g1smd
A code review tool is used to propose changes to the code and metadata and to
review and comment on proposed changes.

When everyone is in agreement, the internal Google version is updated with the
proposed changes.

Once testing is complete, the java code and metadata is pushed to the public
version.

The final steps are to produce the javascript port, and on a less regular
basis the .jar file in the "downloads" section is also updated.

------
elvirs
invalid country code for 994 (Azerbaijan) tried both with 00 and without

~~~
ImJasonH
<http://code.google.com/p/libphonenumber/issues/entry>

~~~
elvirs
thanks

