Hi Kumar,
Not sure whether this is of any help but you can check out https://kamailio.org/docs/modules/5.9.x/modules/phonenum.html module.
BR, Supreeth
On Fri, 31 May 2024 at 10:27, Benoît Panizzon via sr-users < sr-users@lists.kamailio.org> wrote:
Hi Kumar
Before writing the code, I want to know if there is already a solution to this problem in one of the modules, so that I won't reinvent the wheel.
US numbers are fixed lenght 11 digits? What is the usual representation of a 'local' US number? Does it start with a 0?
I do this (to translate Swiss local numbers to e164):
$var(check_number) = "012 345 67 89" # local number example, use $rU or $fU or whatever you want to translate. route(TRANSLATE_TO_e164); $rU = $var(result);
route[TRANSLATE_TO_e164] { $var(result) = 'invalid'; $var(check_number) = $(var(check_number){s.rmws}); # Remove spaces if ($var(check_number) =~ "^+") { $var($result) = $var(check_number); # Already e164 } else if ($var(check_number) =~ "^00") { # international number in local notation replace 00 by + $var(result) = "+" + $(var(check_number){s.substr,2,0}); } else if ($var(check_number) =~ "^0") { # Swiss number in local notation replace 0 by +41 $var(result) = "+41" + $(var(check_number){s.substr,1,0}); } }
And of course I have a corresponding TRANSLATE_TO_LOCAL to display numbers to the customer in a format they are used to in Switzerland.
-- Mit freundlichen Grüssen
-Benoît Panizzon- @ HomeOffice und normal erreichbar
I m p r o W a r e A G - Leiter Commerce Kunden ______________________________________________________
Zurlindenstrasse 29 Tel +41 61 826 93 00 CH-4133 Pratteln Fax +41 61 826 93 01 Schweiz Web http://www.imp.ch ______________________________________________________ __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: