Short Code support?

883 views
Skip to first unread message

mrtnsu

unread,
Mar 19, 2013, 10:08:38 PM3/19/13
to libphonenum...@googlegroups.com
Short codes are "special" telephone numbers:


Is it possible to use libphonenumber to:

* parse and validate short codes (given a phone number string and region code)?
* distinguish a phone number type as either 'longcode' or 'shortcode'?

I see there is a ShortNumberUtil class:


but it appears to only deal with Emergency numbers.

It has a class comment: "Note most commercial short numbers are not handled here, but by the PhoneNumberUtil.".

However, PhoneNumberType does not define a type for "Emergency" (this is expected), nor "ShortCode" (this is unexpected, based on the comment above).

In PhoneNumberMetaData.xml, I see that there is actually metadata for shortcodes defined for a lot of regions, in the "territory/shortCode" node.

In PhoneMetadata, I don't see a property for ShortCode (but there is one, for example, for Emergency, HasEmergency).

Other than this, I'm not aware of any other code that deals with shortcodes.

Currently, when I use PhoneNumberUtil on a phone number that is a shotcode, I get the following results:

Parse(65565, GB): PhoneNumber: {
ToString: PhoneNumbers.PhoneNumber,
CountryCode: 44,
CountryCodeSource: FROM_NUMBER_WITH_PLUS_SIGN,
HasExtension: False,
Extension: ,
HasCountryCode: True,
HasCountryCodeSource: False,
HasItalianLeadingZero: False,
ItalianLeadingZero: False,
HasNationalNumber: True,
NationalNumber: 65565,
HasPreferredDomesticCarrierCode: False,
PreferredDomesticCarrierCode: ,
HasRawInput: False,
IsInitialized: True,
RawInput: 
}

CanBeInternationallyDialled(PhoneNumbers.PhoneNumber): True,
Format(PhoneNumbers.PhoneNumber, E164): +4465565,
Format(PhoneNumbers.PhoneNumber, INTERNATIONAL): +44 65565,
Format(PhoneNumbers.PhoneNumber, NATIONAL): 65565,
Format(PhoneNumbers.PhoneNumber, RFC3966): tel:+44-65565,
FormatInOriginalFormat(PhoneNumbers.PhoneNumber, GB): 65565,
FormatNationalNumberWithCarrierCode(PhoneNumbers.PhoneNumber, ): 65565,
FormatNationalNumberWithPreferredCarrierCode(PhoneNumbers.PhoneNumber, ): 65565,
FormatNumberForMobileDialing(PhoneNumbers.PhoneNumber, GB, True): +44 65565,
FormatNumberForMobileDialing(PhoneNumbers.PhoneNumber, GB, False): +4465565,
FormatOutOfCountryCallingNumber(PhoneNumbers.PhoneNumber, GB): 65565,
FormatOutOfCountryKeepingAlphaChars(PhoneNumbers.PhoneNumber, GB): 65565,
GetLengthOfGeographicalAreaCode(PhoneNumbers.PhoneNumber): 0,
GetLengthOfNationalDestinationCode(PhoneNumbers.PhoneNumber): 0,
GetNationalSignificantNumber(PhoneNumbers.PhoneNumber): 65565,
GetNumberType(PhoneNumbers.PhoneNumber): UNKNOWN,
GetRegionCodeForNumber(PhoneNumbers.PhoneNumber): ,
IsPossibleNumber(PhoneNumbers.PhoneNumber): True,
IsPossibleNumberWithReason(PhoneNumbers.PhoneNumber): IS_POSSIBLE,
IsValidNumber(PhoneNumbers.PhoneNumber): False,
IsValidNumberForRegion(PhoneNumbers.PhoneNumber): False



Thanks in advance for any input.

Cheers, Martin
Message has been deleted

mrtnsu

unread,
Mar 19, 2013, 10:25:20 PM3/19/13
to libphonenum...@googlegroups.com
Some additional info from the release notes:

October 19th, 2011: libphonenumber-4.1
- Add ShortNumberUtil to deal with international short phone numbers, such as short codes and
   emergency numbers.

Jan 20th, 2011
 Metadata changes:
  - New types of numbers introduced: UAN (universal or "company" numbers) and short codes. Note that
    "generalDesc" patterns do not encompass short-codes.  No code-support for these has been
    introduced as of yet. We are also now enabling the collection of data for information such as
    area-code-optional, and no-international-dialling ranges.

The "no code-support" comment on the latter seems to affirm the absence of any short code related code/functionality. Can someone confirm?

Shaopeng

unread,
Mar 20, 2013, 4:02:27 AM3/20/13
to libphonenum...@googlegroups.com
Hello Martin,

It is our plan to build utilities to parse, validate, and type short codes once we have a reasonable collection of short code metadata. We hope to start that work some time next quarter.

Cheers,

Shaopeng


2013/3/20 mrtnsu <m...@mrtn.ca>
--
You received this message because you are subscribed to the Google Groups "libphonenumber-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libphonenumber-di...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Liviu

unread,
Feb 22, 2019, 11:10:47 AM2/22/19
to libphonenumber-discuss
Hi,

Has something been developed towards support short codes?

Thanks,
Liviu


2013/3/20 mrtnsu <m...@mrtn.ca>
To unsubscribe from this group and stop receiving emails from it, send an email to libphonenumber-discuss+unsub...@googlegroups.com.

Andrew Lipman

unread,
Feb 25, 2019, 1:42:34 PM2/25/19
to libphonenumber-discuss
Hi,

Yes we do fully support short codes, we do so however in a separate API.  For short codes you can use our ShortNumberInfo class, https://github.com/googlei18n/libphonenumber/blob/master/java/libphonenumber/src/com/google/i18n/phonenumbers/ShortNumberInfo.java.
Reply all
Reply to author
Forward
0 new messages