[Asterisk-Users] OT?: International number parsing
Francesco Peeters (Asterisk)
francesco at fampeeters.com
Sat Jan 28 10:41:40 MST 2006
On Fri, January 27, 2006 23:47, Script Head said:
> What you're trying to accomplish can be easily done with an SQL query. You
> need to create a table of all the prefixes (international dial+country
> code+city/carrier) and join by that prefix.
>
>
>
>
> On 1/27/06, Damon Estep <damon at suburbanbroadband.net> wrote:
>>
>> Can anyone shed some light on "rules" that might make the task of
>> parsing the country code and city codes from a dialed number in the
>> CDRs?
>>
>> I know that there is almost never a case where a concatenated country
>> and city code could overlap with another country code, but what about
>> city codes and local numbers? Is it possible for a concatenated city
>> code and local number to match another city code in the same country?
>>
>> I already have the table of country and city codes built.
>>
>> Are there holes in this theory;
>>
>> 1. Starting after the international dialing code, find the longest match
>> for country code.
>> 2. Starting after the country code from step 1, find the longest match
>> for city code within that countries table of city codes.
>> 3. The rest is the local number.
>>
>> Are there known exceptions?
>>
>> Am I reinventing the wheel rather than finding the right already
>> existing resource?
>>
>>
Obviously countrycodes are unique, and are created in a few 'classes'
which also always provide unique numbers.
Only one country has a single digit code: USA = 1
Most countries have a 2 digit code (31 = NL, 44 = UK, 49 = DE, etc.) There
are *no* country codes with more than two digits that overlap the 2 digit
codes. (So there's no 3 digit CC that starts with, for example, 31, 44,
49, etc.)
So it is possible to 'categorize' them in to 1, 2, 3 digit CC's.
Also the international dial codes have been chosen to not overlap anything
else. So if you see (for instance) 011 you will always know it is an
international call, and the next 1-3 digits will be a country code.
--
F Peeters
PIII 450 - 1 GB - * 1.2 - BRIstuff 0.3.0 Pre 1 - Florz patch
2 Sweex HFC-PCI modes=2 sync_slave=2 timer_card=0
Cologne HFC-S pins #52, #54, #55 connected in parallel for synching.
AMD Duron 1GHz - 1GB - * 1.2.1
2 Sweex HFC-PCI cards
More information about the asterisk-users
mailing list