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