stringcompare and normalization to find numbers in contacts
Joerg Reisenweber
joerg at openmoko.org
Mon May 18 18:15:43 CEST 2009
normalized number = "+<CC><HC><NUMBER>"
non-normalized my be: <NUMBER> | <NationalPrefix><anyHC><NUMBER> |
<InterntlPrefix><anyCC><anyHC><NUMBER>
so:
Nr1 := Nr s/<IP>(.*)/\+$1/ #00 49 911 12345 -> + 49 911 12345
Nr2 = Nr1 s/<NP>/\+<CC>/ # 0 911 12345 -> + 49 911 12345
Nr3 = Nr2 s/[^\+](.*)/\+<CC><HC>$1/ # 12345 -> + 49 911 12345
step3 above isn't considered very practical for cellphones
<IP>, <CC>, <NP>, and <HC> are user definable config-values
apply normalization to both numbers prior to strcmp() *only* - no mangeling of
numbers on storing, dialing, display to user
nota bene: inbound call numbers are considered fully normalized (per GSM
definition). If you like to cope with non-standards-conforming inbound
numbers, you need a means to acquire CC' of the network currently in use, and
use this CC' instead of CC for normalizing the inbound number.
a good idea might be to cut all spaces as well, and also truncate any
leading/trailing netcode sequences like *31#+49 911 12345 W;1**3 (truncate
from left side and from right side all *short* sequences including any
non-numeric+"+" delimeter, this is "*31#" (excluding the "+"!) for left,
and "W;1**3" for right. Admittedly this part is tricky.
Left side truncation is mandatory, right side a nice-to-have)
cheers
jOERG
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.openmoko.org/pipermail/devel/attachments/20090518/b78c2e1f/attachment.pgp
More information about the devel
mailing list