From 50b6a04c1e7cc65d2d50950f07cb0d1957c81997 Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Thu, 27 Oct 2016 14:24:58 +0100 Subject: [PATCH] add an extra falsehood: that phone numbers are numbers (#1391) --- FALSEHOODS.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/FALSEHOODS.md b/FALSEHOODS.md index 95715c270..1e7f35461 100644 --- a/FALSEHOODS.md +++ b/FALSEHOODS.md @@ -182,8 +182,8 @@ surprising how many false assumptions programmers continue to make about them. These include, but are not limited to: * *Moving within a country*: In countries with phone number portability, you may retain your number when moving, even in some cases if it is a - fixed-line number and even if it has an area code. (See - [xkcd](https://xkcd.com/1129/) for a US example.) + fixed-line number and even if it has an area code (see + *[xkcd](https://xkcd.com/1129/)* for a US example.) * *Moving to another country*: Some people keep their mobile phones when they move to another country. * *Geopolitical turmoil*: Sometimes countries change their borders, cease @@ -226,6 +226,20 @@ surprising how many false assumptions programmers continue to make about them. information. Unless a piece of user-supplied data has actually been verified to be a phone number, it should be stored as-is as entered by the user. +1. **Phone numbers are numbers** + + Never try to store phone numbers as an int or any other kind of numeric + data type. You can't do arithmetic on them, and while 007, 07 and 7 are the + same number they are not necessarily the same phone number - in some + countries a leading 0 is significant and forms part of the number itself + (see *A leading zero in numbers formatted for domestic usage can always be + discarded when dialing from abroad*). Moreover, a phone number may contain + other diallable characters (see *Phone numbers contain only digits*) or an + extension portion, dialled after waiting for a tone. + + **Tip:** Use the library to parse and format numbers to handle this + correctly for every country. + 1. **Phone numbering plans published by governments or telecoms represent reality**