What does HackerNews think of libphonenumber?

Google's common Java, C++ and JavaScript library for parsing, formatting, and validating international phone numbers.

Language: C++

> It seems to be a general trend that countries with variable-length area codes lack well agreed upon phone number formatting conventions. In the UK, for example, there is also variability (albeit much less of it). This speaks to one of the disadvantages of variable-length area codes: they make digit grouping more difficult, as there's a logical desire to group around the "area code" but it's not obvious what part of the number that is.

It’s trivial for computers. For example, using Google’s libphonenumber [0]. For example, Poland uses `000 000 000` for mobiles, and `00 000 00 00` for landlines. libphonenumber knows how to handle this [1]:

        
        
          
            21|
            39|
            45|
            5[0137]|
            6[0469]|
            7[02389]|
            8(?:
              0[14]|
              8
            )
          
          $1 $2 $3
        
        
        
          
            1[2-8]|
            [2-7]|
            8[1-79]|
            9[145]
          
          $1 $2 $3 $4
        
[0]: https://github.com/google/libphonenumber [1]: https://github.com/google/libphonenumber/blob/master/resourc...
> It's not like being just a little more flexible with input formatting is a major feature with huge implementation costs and security risks, either.

Just in case somebody considers implementing phone number parsing and normalizing: Just don't and use Googles libphonenumber, which offers solid, ready to use implementations in various languages (there also exist ports for other languages too): https://github.com/google/libphonenumber/

Not in any particular order, but here is a list of really useful text butchering utilities, that I keep in the same grab-bag as ftfy: csvclean[1], unidecode[2], transliterate[3], charset-normalizer[4], cchardet[5], phonenumbers[6][7], iconv[8], enca/enconv[9].

[1] https://csvkit.readthedocs.io/en/1.0.3/scripts/csvclean.html

[2] https://pypi.org/project/Unidecode/

[3] https://pypi.org/project/transliterate/

[4] https://pypi.org/project/charset-normalizer/

[5] https://pypi.org/project/cchardet/

[6] https://pypi.org/project/phonenumbers/

[7] which is a python port of Google's libphonenumber: https://github.com/google/libphonenumber

[8] https://linux.die.net/man/1/iconv

[9] https://linux.die.net/man/1/enca