nitingautam / smslib

Automatically exported from code.google.com/p/smslib
0 stars 0 forks source link

Identification of international number is broken for longer numbers (more than 12 digits) #364

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

in germany some providers are using long mobile phone numbers. Sending
messages to this numbers is currently only possible if the number starts
with +, while sending sms to numbers with normal length (12digits) is
working without a + in front.

I think, the problem is in PduUtils.getAddressTypeFor(address). There is an
assumption, that international numbers are always exactly 12 digits long.
But as i already wrote, we now have more than 12 digits as international
styled phone number.

As detailed example there are:
* 2 digits for international code area (49 in germany)
* 3 digits for mobile phone provider (eg. 151 for T-Mobile Germany)
* 8 digits for mobile phone number itself

So we have in total 13 digits for an international styled number.

Please take a closer look to E.164 (http://en.wikipedia.org/wiki/E.164).
Based on this information international numbers have up to 15 digits.

Original issue reported on code.google.com by steffen....@gmail.com on 3 Jun 2010 at 9:54

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 3 Jun 2010 at 6:59

GoogleCodeExporter commented 9 years ago
I think all you need to do is change the method public static int 
getAddressTypeFor(String address) in PduUtils.java

to have 

if ((address.length() == 15) || (international))

instead of 

if ((address.length() == 12) || (international))

or 13 if that is the max for you

Original comment by jjon...@gmail.com on 10 Jun 2010 at 9:46

GoogleCodeExporter commented 9 years ago
Hi,

if I change the source as you suggested, every SMS number with 12 digits would 
not be recognized as international. But this would be absolutely wrong! Both is 
right in germany. I am not looking to find a work around for me, but for a way 
it get it working for all SMSLib-/ SMSServer users.

The easiest way would be to add always a leading + for international numbers. 
But SMS-numbers of incoming messages do not have an + infront (i think). So 
this would be inconsistent in SMSlib resp. SMSServer.

Honestly, I do not have the good idea to solve this problem. But I think it is 
an serious one.

One way would be to standardize the usage of leading + in all parts of SMSLib/ 
SMSServer. So you could remove an detection of international numbers by length. 
I think this would be the straight way, which is also easy to implement. But 
maybe this breaks applications, which does not expect leading +. 

An other way could be to implement a detection of international numbers be 
validating country and regional calling codes. This would be very much work in 
comparison to the first idea, but should not break any application. On the 
other side, I am not sure if you/ we could get this detection working for every 
number world wide with 100%.

So I am not sure, what to do. Please think about it again. 
I am waiting for your comments :)

Greetings from Germany,

Steffen

Original comment by steffen....@gmail.com on 10 Jun 2010 at 10:25

GoogleCodeExporter commented 9 years ago
What sorts of combinations are allowed?  So 12 digits with or without + is 
international.  Anything with a + is international.  13 is automatically 
international?

The only this I can think of is to define a regular expression that will define 
whether the number in international or not and making this some kind of 
parameter or global setting.  So by default it can be something like (\d{12}) | 
(\+\d[1-12]).

In your case it might be something like (\d{12}) | (\+\d[1-15])

Original comment by jjon...@gmail.com on 10 Jun 2010 at 10:37

GoogleCodeExporter commented 9 years ago
Hi,

unfortunately many combinations are allowed, as you can read here 
(http://en.wikipedia.org/wiki/E.164) or in original specification 
(http://www.itu.int/rec/T-REC-E.164-200502-I/en).

The maximum length of international numbers is fifteen digits. Before 1997 only 
twelve digits were allowed.

Every international number starts with a country code. The length of country 
code varied between 1 and 3. For example USA has +1, germany +49 and Irland 
+353. (http://en.wikipedia.org/wiki/List_of_country_calling_codes)

Country code is follewed by one of this four structures:
a) National Destination Code (optional)  + Subscriber Number
   which are together a National (significant) number
b) Global Subscriber Number
c) Identification Code + Subscriber Number
d) Group Identification Code + Subscriber Number

All these number have a maximum length of 15 - Country Code, but there is _no_ 
minimal length. 

This means that every number with 15 digits is international. Every shorter 
number could be international. If I understand it right, in US even an 14 digit 
telefon number could be only a national number, because US only have a 1 digit 
country code. Also a number shorter that 12 digits, could be an international 
number. I do not have any proofs to this and no examples, but I think it would 
follow the international public telecommunication numbering plan E.164.

As more as I think about it, I like the straight way to always use leading + 
for international numbers more.

For your regular expression idea take a look at this blog 
http://blog.stevenlevithan.com/archives/validate-phone-number#r4-3

Greetings,

Steffen

Original comment by steffen....@gmail.com on 10 Jun 2010 at 11:55

GoogleCodeExporter commented 9 years ago
Hi,

Can we all agree that a "+" is the *one and only* indication to denote an 
international number?

Original comment by T.Delenikas on 18 Jul 2010 at 6:26

GoogleCodeExporter commented 9 years ago
Correction:

Can we all agree that a "+" should be the *one and only* indication to denote 
an international number?

Original comment by T.Delenikas on 18 Jul 2010 at 6:30

GoogleCodeExporter commented 9 years ago
Noone???

I guess that, in lack of any feedback, I will go with the "+" solution once the 
new version is ready for launch.

Original comment by T.Delenikas on 30 Jul 2010 at 8:31

GoogleCodeExporter commented 9 years ago
Hello,

sorry for my delay, I was in holiday.

I think, you are right, "+" should be the "one and only" indication for 
international numbers. 
For consistency it should be used in any other cases as well (e.g. incoming sms 
and calls). I currently do not know, if it is used there.

Greetings,

Steffen

Original comment by steffen....@gmail.com on 30 Jul 2010 at 9:45

GoogleCodeExporter commented 9 years ago
r2227 : should we settle on this code?

Original comment by T.Delenikas on 8 Aug 2010 at 11:17

GoogleCodeExporter commented 9 years ago
Yes, looks good.

Original comment by steffen....@gmail.com on 8 Aug 2010 at 11:29

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 8 Aug 2010 at 11:39

GoogleCodeExporter commented 9 years ago
Leaving this open in order to ensure that inbound international numbers are 
prefixed with "+" as well (uniformity)...

Original comment by T.Delenikas on 8 Aug 2010 at 11:45

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 9 Aug 2010 at 6:13

GoogleCodeExporter commented 9 years ago

Original comment by T.Delenikas on 13 Nov 2010 at 8:16