Is there a standard for storing normalized phone numbers in a database?

前端 未结 18 1508
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 19:23

What is a good data structure for storing phone numbers in database fields? I\'m looking for something that is flexible enough to handle international numbers, and also som

18条回答
  •  伪装坚强ぢ
    2020-11-28 19:46

    Look up E.164. Basically, you store the phone number as a code starting with the country prefix and an optional pbx suffix. Display is then a localization issue. Validation can also be done, but it's also a localization issue (based on the country prefix).

    For example, +12125551212+202 would be formatted in the en_US locale as (212) 555-1212 x202. It would have a different format in en_GB or de_DE.

    There is quite a bit of info out there about ITU-T E.164, but it's pretty cryptic.

提交回复
热议问题