// for representing the accented o - the character itself, and one in the unicode decomposed
// form with the combining acute accent.
return (RFC3966_EXTN_PREFIX + CAPTURING_EXTN_DIGITS + "|" + "[ \u00A0\\t,]*" +
- "(?:ext(?:ensi(?:o\u0301?|\u00F3))?n?|\uFF45\uFF58\uFF54\uFF4E?|" +
+ "(?:e?xt(?:ensi(?:o\u0301?|\u00F3))?n?|\uFF45?\uFF58\uFF54\uFF4E?|" +
"[" + singleExtnSymbols + "]|int|anexo|\uFF49\uFF4E\uFF54)" +
"[:\\.\uFF0E]?[ \u00A0\\t,-]*" + CAPTURING_EXTN_DIGITS + "#?|" +
"[- ]+(" + DIGITS + "{1,5})#");
// Used for "Universal Access Numbers" or "Company Numbers". They may be further routed to
// specific offices, but allow one number to be used for a company.
UAN,
+ // Used for "Voice Mail Access Numbers".
+ VOICEMAIL,
// A phone number is of type UNKNOWN when it does not fit any of the known patterns for a
// specific region.
UNKNOWN
/**
* Used for testing purposes only to reset the PhoneNumberUtil singleton to null.
*/
+ // @VisibleForTesting
static synchronized void resetInstance() {
instance = null;
}
return;
}
- formattedNumber.append(formatNationalNumber(nationalSignificantNumber,
- regionCode, numberFormat));
- maybeGetFormattedExtension(number, regionCode, numberFormat, formattedNumber);
+ PhoneMetadata metadata = getMetadataForRegion(regionCode);
+ formattedNumber.append(formatNationalNumber(nationalSignificantNumber, metadata, numberFormat));
+ maybeGetFormattedExtension(number, metadata, numberFormat, formattedNumber);
formatNumberByFormat(countryCallingCode, numberFormat, formattedNumber);
}
}
List<NumberFormat> userDefinedFormatsCopy =
new ArrayList<NumberFormat>(userDefinedFormats.size());
+ PhoneMetadata metadata = getMetadataForRegion(regionCode);
for (NumberFormat numFormat : userDefinedFormats) {
String nationalPrefixFormattingRule = numFormat.getNationalPrefixFormattingRule();
if (nationalPrefixFormattingRule.length() > 0) {
// appropriate national prefix.
NumberFormat numFormatCopy = new NumberFormat();
numFormatCopy.mergeFrom(numFormat);
- String nationalPrefix = getMetadataForRegion(regionCode).getNationalPrefix();
+ String nationalPrefix = metadata.getNationalPrefix();
if (nationalPrefix.length() > 0) {
// Replace $NP with national prefix and $FG with the first group ($1).
nationalPrefixFormattingRule =
new StringBuilder(formatAccordingToFormats(nationalSignificantNumber,
userDefinedFormatsCopy,
numberFormat));
- maybeGetFormattedExtension(number, regionCode, numberFormat, formattedNumber);
+ maybeGetFormattedExtension(number, metadata, numberFormat, formattedNumber);
formatNumberByFormat(countryCallingCode, numberFormat, formattedNumber);
return formattedNumber.toString();
}
}
StringBuilder formattedNumber = new StringBuilder(20);
+ PhoneMetadata metadata = getMetadataForRegion(regionCode);
formattedNumber.append(formatNationalNumber(nationalSignificantNumber,
- regionCode,
+ metadata,
PhoneNumberFormat.NATIONAL,
carrierCode));
- maybeGetFormattedExtension(number, regionCode, PhoneNumberFormat.NATIONAL, formattedNumber);
+ maybeGetFormattedExtension(number, metadata, PhoneNumberFormat.NATIONAL, formattedNumber);
formatNumberByFormat(countryCallingCode, PhoneNumberFormat.NATIONAL, formattedNumber);
return formattedNumber.toString();
}
// Details here: http://www.petitfute.com/voyage/225-info-pratiques-reunion
return format(number, PhoneNumberFormat.NATIONAL);
}
- String formattedNationalNumber =
- formatNationalNumber(nationalSignificantNumber,
- regionCode, PhoneNumberFormat.INTERNATIONAL);
- PhoneMetadata metadata = getMetadataForRegion(regionCallingFrom);
- String internationalPrefix = metadata.getInternationalPrefix();
+ PhoneMetadata metadataForRegionCallingFrom = getMetadataForRegion(regionCallingFrom);
+ String internationalPrefix = metadataForRegionCallingFrom.getInternationalPrefix();
// For regions that have multiple international prefixes, the international format of the
// number is returned, unless there is a preferred international prefix.
String internationalPrefixForFormatting = "";
if (UNIQUE_INTERNATIONAL_PREFIX.matcher(internationalPrefix).matches()) {
internationalPrefixForFormatting = internationalPrefix;
- } else if (metadata.hasPreferredInternationalPrefix()) {
- internationalPrefixForFormatting = metadata.getPreferredInternationalPrefix();
+ } else if (metadataForRegionCallingFrom.hasPreferredInternationalPrefix()) {
+ internationalPrefixForFormatting =
+ metadataForRegionCallingFrom.getPreferredInternationalPrefix();
}
+ PhoneMetadata metadataForRegion = getMetadataForRegion(regionCode);
+ String formattedNationalNumber =
+ formatNationalNumber(nationalSignificantNumber,
+ metadataForRegion, PhoneNumberFormat.INTERNATIONAL);
StringBuilder formattedNumber = new StringBuilder(formattedNationalNumber);
- maybeGetFormattedExtension(number, regionCode, PhoneNumberFormat.INTERNATIONAL,
+ maybeGetFormattedExtension(number, metadataForRegion, PhoneNumberFormat.INTERNATIONAL,
formattedNumber);
if (internationalPrefixForFormatting.length() > 0) {
formattedNumber.insert(0, " ").insert(0, countryCallingCode).insert(0, " ")
* Formats a phone number using the original phone number format that the number is parsed from.
* The original format is embedded in the country_code_source field of the PhoneNumber object
* passed in. If such information is missing, the number will be formatted into the NATIONAL
- * format by default. When the number is an invalid number, the method returns the raw input when
- * it is available.
+ * format by default. When the number contains a leading zero and this is unexpected for this
+ * country, or we don't have a formatting pattern for the number, the method returns the raw input
+ * when it is available.
*
* @param number the phone number that needs to be formatted in its original number format
* @param regionCallingFrom the region whose IDD needs to be prefixed if the original number
*/
public String formatInOriginalFormat(PhoneNumber number, String regionCallingFrom) {
if (number.hasRawInput() &&
- (!hasFormattingPatternForNumber(number) || !isValidNumber(number))) {
+ (hasUnexpectedItalianLeadingZero(number) || !hasFormattingPatternForNumber(number))) {
// We check if we have the formatting pattern because without that, we might format the number
- // as a group without national prefix. We also want to check the validity of the number
- // because we don't want to risk formatting the number if we don't really understand it.
+ // as a group without national prefix.
return number.getRawInput();
}
if (!number.hasCountryCodeSource()) {
}
}
+ /**
+ * Returns true if a number is from a region whose national significant number couldn't contain a
+ * leading zero, but has the italian_leading_zero field set to true.
+ */
+ private boolean hasUnexpectedItalianLeadingZero(PhoneNumber number) {
+ return number.isItalianLeadingZero() && !isLeadingZeroPossible(number.getCountryCode());
+ }
+
private boolean hasFormattingPatternForNumber(PhoneNumber number) {
String phoneNumberRegion = getRegionCodeForCountryCode(number.getCountryCode());
PhoneMetadata metadata = getMetadataForRegion(phoneNumberRegion);
? internationalPrefix
: metadata.getPreferredInternationalPrefix();
StringBuilder formattedNumber = new StringBuilder(rawInput);
- maybeGetFormattedExtension(number, regionCode, PhoneNumberFormat.INTERNATIONAL,
- formattedNumber);
+ maybeGetFormattedExtension(number, getMetadataForRegion(regionCode),
+ PhoneNumberFormat.INTERNATIONAL, formattedNumber);
if (internationalPrefixForFormatting.length() > 0) {
formattedNumber.insert(0, " ").insert(0, countryCode).insert(0, " ")
.insert(0, internationalPrefixForFormatting);
// Simple wrapper of formatNationalNumber for the common case of no carrier code.
private String formatNationalNumber(String number,
- String regionCode,
+ PhoneMetadata metadata,
PhoneNumberFormat numberFormat) {
- return formatNationalNumber(number, regionCode, numberFormat, null);
+ return formatNationalNumber(number, metadata, numberFormat, null);
}
// Note in some regions, the national number can be written in two completely different ways
// numberFormat parameter here is used to specify which format to use for those cases. If a
// carrierCode is specified, this will be inserted into the formatted string to replace $CC.
private String formatNationalNumber(String number,
- String regionCode,
+ PhoneMetadata metadata,
PhoneNumberFormat numberFormat,
String carrierCode) {
- PhoneMetadata metadata = getMetadataForRegion(regionCode);
List<NumberFormat> intlNumberFormats = metadata.intlNumberFormats();
// When the intlNumberFormats exists, we use that to format national number for the
// INTERNATIONAL format instead of using the numberDesc.numberFormats.
* Appends the formatted extension of a phone number to formattedNumber, if the phone number had
* an extension specified.
*/
- private void maybeGetFormattedExtension(PhoneNumber number, String regionCode,
+ private void maybeGetFormattedExtension(PhoneNumber number, PhoneMetadata metadata,
PhoneNumberFormat numberFormat,
StringBuilder formattedNumber) {
if (number.hasExtension() && number.getExtension().length() > 0) {
if (numberFormat == PhoneNumberFormat.RFC3966) {
formattedNumber.append(RFC3966_EXTN_PREFIX).append(number.getExtension());
} else {
- formatExtension(number.getExtension(), regionCode, formattedNumber);
+ formatExtension(number.getExtension(), metadata, formattedNumber);
}
}
}
* prefix. This will be the default extension prefix, unless overridden by a preferred
* extension prefix for this region.
*/
- private void formatExtension(String extensionDigits, String regionCode,
+ private void formatExtension(String extensionDigits, PhoneMetadata metadata,
StringBuilder extension) {
- PhoneMetadata metadata = getMetadataForRegion(regionCode);
if (metadata.hasPreferredExtnPrefix()) {
extension.append(metadata.getPreferredExtnPrefix()).append(extensionDigits);
} else {
return metadata.getPager();
case UAN:
return metadata.getUan();
+ case VOICEMAIL:
+ return metadata.getVoicemail();
default:
return metadata.getGeneralDesc();
}
if (isNumberMatchingDesc(nationalNumber, metadata.getUan())) {
return PhoneNumberType.UAN;
}
+ if (isNumberMatchingDesc(nationalNumber, metadata.getVoicemail())) {
+ return PhoneNumberType.VOICEMAIL;
+ }
boolean isFixedLine = isNumberMatchingDesc(nationalNumber, metadata.getFixedLine());
if (isFixedLine) {
* @param number the phone-number for which we want to know whether it is only diallable from
* within the region
*/
+ // @VisibleForTesting
boolean canBeInternationallyDialled(PhoneNumber number) {
String regionCode = getRegionCodeForNumber(number);
String nationalSignificantNumber = getNationalSignificantNumber(number);
return this;
}
+ // required PhoneNumberDesc voicemail = 28;
+ private boolean hasVoicemail;
+ private PhoneNumberDesc voicemail_ = null;
+ public boolean hasVoicemail() { return hasVoicemail; }
+ public PhoneNumberDesc getVoicemail() { return voicemail_; }
+ public PhoneMetadata setVoicemail(PhoneNumberDesc value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ hasVoicemail = true;
+ voicemail_ = value;
+ return this;
+ }
+
// required PhoneNumberDesc emergency = 27;
private boolean hasEmergency;
private PhoneNumberDesc emergency_ = null;
if (hasUan) {
uan_.writeExternal(objectOutput);
}
+ objectOutput.writeBoolean(hasVoicemail);
+ if (hasVoicemail) {
+ voicemail_.writeExternal(objectOutput);
+ }
objectOutput.writeBoolean(hasEmergency);
if (hasEmergency) {
emergency_.writeExternal(objectOutput);
if (hasDesc) {
PhoneNumberDesc desc = new PhoneNumberDesc();
desc.readExternal(objectInput);
+ setVoicemail(desc);
+ }
+ hasDesc = objectInput.readBoolean();
+ if (hasDesc) {
+ PhoneNumberDesc desc = new PhoneNumberDesc();
+ desc.readExternal(objectInput);
setEmergency(desc);
}
hasDesc = objectInput.readBoolean();
PhoneNumber number5 = phoneUtil.parse("+442087654321", RegionCode.GB);
assertEquals("(020) 8765 4321", phoneUtil.formatInOriginalFormat(number5, RegionCode.GB));
- // Invalid numbers should be formatted using its raw input when that is available. Note area
+ // Invalid numbers that we have a formatting pattern for should be formatted properly. Note area
// codes starting with 7 are intentionally excluded in the test metadata for testing purposes.
PhoneNumber number6 = phoneUtil.parseAndKeepRawInput("7345678901", RegionCode.US);
- assertEquals("7345678901", phoneUtil.formatInOriginalFormat(number6, RegionCode.US));
+ assertEquals("734 567 8901", phoneUtil.formatInOriginalFormat(number6, RegionCode.US));
- // When the raw input is unavailable, format as usual.
- PhoneNumber number7 = phoneUtil.parse("7345678901", RegionCode.US);
- assertEquals("734 567 8901", phoneUtil.formatInOriginalFormat(number7, RegionCode.US));
+ // US is not a leading zero country, and the presence of the leading zero leads us to format the
+ // number using raw_input.
+ PhoneNumber number7 = phoneUtil.parseAndKeepRawInput("07345678901", RegionCode.US);
+ assertEquals("07345678901", phoneUtil.formatInOriginalFormat(number7, RegionCode.US));
// This number is valid, but we don't have a formatting pattern for it. Fall back to the raw
// input.
PhoneNumber number8 = phoneUtil.parseAndKeepRawInput("02-4567-8900", RegionCode.KR);
assertEquals("02-4567-8900", phoneUtil.formatInOriginalFormat(number8, RegionCode.KR));
+
+ // US local numbers are formatted correctly, as we have formatting patterns for them.
+ PhoneNumber localNumberUS = phoneUtil.parseAndKeepRawInput("2530000", RegionCode.US);
+ assertEquals("253 0000", phoneUtil.formatInOriginalFormat(localNumberUS, RegionCode.US));
}
public void testIsPremiumRate() {
assertEquals(ukNumber, phoneUtil.parse("+44 2034567890 x 456 ", RegionCode.GB));
assertEquals(ukNumber, phoneUtil.parse("+44 2034567890 X 456", RegionCode.GB));
assertEquals(ukNumber, phoneUtil.parse("+44-2034567890;ext=456", RegionCode.GB));
+ // Full-width extension, "extn" only.
+ assertEquals(ukNumber, phoneUtil.parse("+442034567890\uFF45\uFF58\uFF54\uFF4E456",
+ RegionCode.GB));
+ // "xtn" only.
+ assertEquals(ukNumber, phoneUtil.parse("+442034567890\uFF58\uFF54\uFF4E456",
+ RegionCode.GB));
+ // "xt" only.
+ assertEquals(ukNumber, phoneUtil.parse("+442034567890\uFF58\uFF54456",
+ RegionCode.GB));
PhoneNumber usWithExtension = new PhoneNumber();
usWithExtension.setCountryCode(1).setNationalNumber(8009013355L).setExtension("7246433");
+December 9th, 2011: libphonenumber-4.4
+* Code changes
+ - Support for Voicemail numbers
+ - Support prefixes "xt" and "xtn" to indicate extensions of phone numbers
+ - Change formatInOriginalFormat to use raw_input for numbers with incorrect leading zeroes, instead
+ of all invalid numbers.
+
+* Metadata changes
+ - Updates for AR, BD, CH, CI, IL, IR, IS, IT, JP, KW, LR, MM, NG, SA, SC, UZ
+
November 24th, 2011: libphonenumber-4.3
* Code changes
- Fix the problems with AYTF crashing for longer numbers entered with +CountryCode, and incorrectly
<!ELEMENT territories (territory+)>
<!ELEMENT territory (availableFormats?, generalDesc?, noInternationalDialling?,
areaCodeOptional?, fixedLine?, mobile?, pager?, tollFree?, premiumRate?,
- sharedCost?, personalNumber?, voip?, uan?, shortCode?, emergency?)>
+ sharedCost?, personalNumber?, voip?, uan?, voicemail?, shortCode?, emergency?)>
<!ELEMENT generalDesc (nationalNumberPattern, possibleNumberPattern)>
- <!ELEMENT noInternationalDialling (nationalNumberPattern, possibleNumberPattern,
+ <!ELEMENT noInternationalDialling (nationalNumberPattern, possibleNumberPattern?,
exampleNumber?)>
<!ELEMENT areaCodeOptional (nationalNumberPattern, possibleNumberPattern, exampleNumber?)>
<!ELEMENT fixedLine (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT personalNumber (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT voip (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT uan (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
+ <!ELEMENT voicemail (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT shortCode (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT emergency (nationalNumberPattern?, possibleNumberPattern?, exampleNumber?)>
<!ELEMENT availableFormats (numberFormat+)>
2(?:
2[013]|
37|
- 6[14]|
- 9[179]
+ 6[146]|
+ 80|
+ 9[17-9]
)|
3(?:
4[1235]|
5[138]|
+ 76|
8[1578]
)
</leadingDigits>
+ <leadingDigits>
+ 2(?:
+ 2[013]|
+ 37|
+ 6[146]|
+ 80|
+ 9[17-9]
+ )|
+ 3(?:
+ 4[1235]|
+ 5(?:
+ [18]|
+ 3[0-35689]
+ )|
+ 76|
+ 8(?:
+ [15]|
+ 7[0-24-9]|
+ 8[0-79]
+ )
+ )
+ </leadingDigits>
+ <format>$1 $2-$3</format>
+ </numberFormat>
+ <numberFormat pattern="(\d{4})(\d{3})(\d{3})">
+ <leadingDigits>
+ 3(?:
+ 53|
+ 8[78]
+ )
+ </leadingDigits>
+ <leadingDigits>
+ 3(?:
+ 537|
+ 8(?:
+ 73|
+ 88
+ )
+ )
+ </leadingDigits>
<format>$1 $2-$3</format>
</numberFormat>
<numberFormat pattern="(\d{4})(\d{2})(\d{4})">
)|
47[3-8]|
6(?:
- [01345]\d|
+ [013-6]\d|
2[2-7]
)|
+ 80\d|
9(?:
[0124789]\d|
3[1-6]|
<fixedLine>
<!-- There was a plan to move to 10 digit fixed-line numbers, but this does not seem to have
been realised, judging by online numbers and wikipedia. These patterns are grouped
- first by leading digit, then within by number of digits. Several Dhaka prefixes (02
- 731, 751 etc) are included despite not being mentioned on the wikipedia page due to
+ first by leading digit, then within by number of digits. Several Dhaka prefixes (02 731
+ etc) are included despite not being mentioned on the wikipedia page or ITU doc due to
online evidence. Another oddity is Chittagong - some numbers have a leading 2, others
do not - both are allowed for now. -->
<nationalNumberPattern>
2(?:
- 7\d1|
+ 7(?:
+ 1[0-267]|
+ 2[0-289]|
+ 3[0-29]|
+ [46][01]|
+ 5[1-3]|
+ 7[017]|
+ 91
+ )|
8(?:
- [026]1|
- [1379][1-5]|
+ 0[125]|
+ [139][1-6]|
+ 2[0157-9]|
+ 6[1-35]|
+ 7[1-5]|
8[1-8]
)|
9(?:
0[0-2]|
1[1-4]|
- 3[3-5]|
- 5[56]|
- 6[67]|
- 71|
- 8[078]
+ 2[568]|
+ 3[3-6]|
+ 5[5-7]|
+ 6[0167]|
+ 7[15]|
+ 8[016-8]
)
)\d{4}|
3(?:
<possibleNumberPattern>\d{10}</possibleNumberPattern>
<exampleNumber>8001234567</exampleNumber>
</tollFree>
+ <shortCode>
+ <nationalNumberPattern>
+ 1(?:
+ 0(?:
+ [39]|
+ 5(?:
+ 0\d|
+ [1-4]
+ )|
+ 6\d{2}|
+ 7[0-4]|
+ 8[0-29]
+ )|
+ 1[6-9]|
+ 2(?:
+ 2[0-5]|
+ [34]
+ )|
+ 3(?:
+ 1\d?|
+ 3\d|
+ 6[3-6]
+ )|
+ 4(?:
+ 0\d|
+ 1\d{2}
+ )|
+ 5[2-9]
+ )
+ </nationalNumberPattern>
+ <possibleNumberPattern>\d{3,5}</possibleNumberPattern>
+ <exampleNumber>103</exampleNumber>
+ </shortCode>
<emergency>
- <nationalNumberPattern>999</nationalNumberPattern>
+ <nationalNumberPattern>
+ 10[0-2]|
+ 999
+ </nationalNumberPattern>
<possibleNumberPattern>\d{3}</possibleNumberPattern>
<exampleNumber>999</exampleNumber>
</emergency>
</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
+ <numberFormat pattern="(\d{3})(\d{2})(\d{3})(\d{2})(\d{2})">
+ <leadingDigits>860</leadingDigits>
+ <format>$1 $2 $3 $4 $5</format>
+ </numberFormat>
</availableFormats>
<generalDesc>
- <nationalNumberPattern>[2-9]\d{8}</nationalNumberPattern>
- <possibleNumberPattern>\d{9}</possibleNumberPattern>
+ <nationalNumberPattern>
+ [2-9]\d{8}|
+ 860\d{9}
+ </nationalNumberPattern>
+ <possibleNumberPattern>\d{9}(?:\d{3})?</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>
[7-9]1
)\d{7}
</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>212345678</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>7[46-9]\d{7}</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>741234567</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>800\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>800123456</exampleNumber>
</tollFree>
<premiumRate>
<nationalNumberPattern>90[016]\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>900123456</exampleNumber>
</premiumRate>
<sharedCost>
<nationalNumberPattern>84[0248]\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>840123456</exampleNumber>
</sharedCost>
<personalNumber>
<nationalNumberPattern>878\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>878123456</exampleNumber>
</personalNumber>
+ <voicemail>
+ <nationalNumberPattern>860\d{9}</nationalNumberPattern>
+ <possibleNumberPattern>\d{12}</possibleNumberPattern>
+ <exampleNumber>860123456789</exampleNumber>
+ </voicemail>
<emergency>
<nationalNumberPattern>
1(?:
<exampleNumber>21234567</exampleNumber>
</fixedLine>
<mobile>
- <!-- Added the prefixes 40, 57 & 65 because SMS messages have been successfully delivered.
+ <!-- Added the prefixes 40, 57-9 & 65 because SMS messages have been successfully delivered.
Supported by numbers found on the internet. -->
<nationalNumberPattern>
(?:
0[1-9]|
4[04-9]|
- 5[07]|
+ 5[07-9]|
6[0567]
)\d{6}
</nationalNumberPattern>
<leadingDigits>121</leadingDigits>
<format>$1-$2-$3</format>
</numberFormat>
+ <!-- The following is for voicemail access. -->
+ <numberFormat pattern="(1599)(\d{6})">
+ <leadingDigits>15</leadingDigits>
+ <format>$1-$2</format>
+ </numberFormat>
<!-- These are 4-digit star numbers which are only accessible within Israel and must be
dialed with a star in front of the number. -->
<numberFormat pattern="(\d{4})">
<possibleNumberPattern>\d{4}</possibleNumberPattern>
<exampleNumber>2250</exampleNumber>
</uan>
+ <voicemail>
+ <nationalNumberPattern>1599\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{10}</possibleNumberPattern>
+ <exampleNumber>1599123456</exampleNumber>
+ </voicemail>
<shortCode>
<nationalNumberPattern>1\d{3}</nationalNumberPattern>
<possibleNumberPattern>\d{4}</possibleNumberPattern>
<nationalNumberPattern>
9(?:
1\d|
- 3[124-8]
+ 3[124-9]
)\d{7}
</nationalNumberPattern>
<possibleNumberPattern>\d{10}</possibleNumberPattern>
<!-- Iceland -->
<!-- http://www.pta.is/default.aspx?cat_id=85 -->
+ <!-- http://www.pfs.is/default.aspx?cat_id=14&module_id=210&element_id=4 -->
<territory id="IS" countryCode="354" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<exampleNumber>4101234</exampleNumber>
</fixedLine>
<mobile>
+ <!-- TETRA = TErrestrial Trunked RAdio is included under mobile. -->
<nationalNumberPattern>
38[59]\d{6}|
(?:
6(?:
1[0-8]|
- 2[0-8]|
3[0-27-9]|
- 4[0-29]|
- 5[029]|
+ 4[0-27]|
+ 5[0-29]|
[67][0-69]|
- [89]\d
+ 9\d
)|
7(?:
5[057]|
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>4931234</exampleNumber>
</voip>
+ <voicemail>
+ <nationalNumberPattern>
+ 388\d{6}|
+ (?:
+ 6(?:
+ 2[0-8]|
+ 49|
+ 8\d
+ )|
+ 8(?:
+ 2[6-9]|
+ [38]\d|
+ 50|
+ 7[014-9]
+ )|
+ 95[48]
+ )\d{4}
+ </nationalNumberPattern>
+ <exampleNumber>388123456</exampleNumber>
+ </voicemail>
<emergency>
<nationalNumberPattern>112</nationalNumberPattern>
<possibleNumberPattern>\d{3}</possibleNumberPattern>
</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
+ <numberFormat pattern="(\d{3})(\d{4})(\d{4})">
+ <leadingDigits>3</leadingDigits>
+ <format>$1 $2 $3</format>
+ </numberFormat>
<numberFormat pattern="(\d{3})(\d{3,6})">
<leadingDigits>
8(?:
<generalDesc>
<nationalNumberPattern>
[0189]\d{5,10}|
- 3\d{8,9}
+ 3(?:
+ [12457-9]\d{8}|
+ [36]\d{7,9}
+ )
</nationalNumberPattern>
<possibleNumberPattern>\d{6,11}</possibleNumberPattern>
</generalDesc>
<exampleNumber>0212345678</exampleNumber>
</fixedLine>
<mobile>
- <nationalNumberPattern>3\d{8,9}</nationalNumberPattern>
- <possibleNumberPattern>\d{9,10}</possibleNumberPattern>
- <exampleNumber>312345678</exampleNumber>
+ <!-- According to wikipedia, TIM mobile numbers can be 9 digits long, but all others are 10
+ digits long. However, a user reported the existence of new 11 digit long numbers for
+ TIM with the prefix 33X, so this is supported also. -->
+ <nationalNumberPattern>
+ 3(?:
+ [12457-9]\d{8}|
+ 6\d{7,8}|
+ 3\d{7,9}
+ )
+ </nationalNumberPattern>
+ <possibleNumberPattern>\d{9,11}</possibleNumberPattern>
+ <exampleNumber>3123456789</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>
882[1245]\d{4}
)
</nationalNumberPattern>
+ <possibleNumberPattern>\d{7,9}</possibleNumberPattern>
<exampleNumber>0777012</exampleNumber>
</noInternationalDialling>
<fixedLine>
<leadingDigits>5</leadingDigits>
<format>$1 $2</format>
</numberFormat>
+ <numberFormat pattern="(65816)(\d{6})">
+ <leadingDigits>65816</leadingDigits>
+ <format>$1 $2</format>
+ </numberFormat>
</availableFormats>
<generalDesc>
- <nationalNumberPattern>[12569]\d{6,7}</nationalNumberPattern>
- <possibleNumberPattern>\d{7,8}</possibleNumberPattern>
+ <nationalNumberPattern>
+ [12569]\d{6,7}|
+ 65816\d{6}
+ </nationalNumberPattern>
+ <possibleNumberPattern>\d{7,8}|\d{11}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>
)
)\d{4}
</nationalNumberPattern>
+ <possibleNumberPattern>\d{7,8}</possibleNumberPattern>
<exampleNumber>22345678</exampleNumber>
</fixedLine>
<mobile>
)|
6(?:
0[034679]|
- 5[015-9]|
+ 5(?:
+ [015-79]|
+ 8(?:
+ [02-9]|
+ 1[0-57-9]
+ )
+ )|
6\d|
7[067]|
9[69]
<exampleNumber>50012345</exampleNumber>
</mobile>
<!-- No tollFree or premiumRate information can be found. -->
+ <voicemail>
+ <!-- Wataniya Telecom -->
+ <nationalNumberPattern>65816\d{6}</nationalNumberPattern>
+ <possibleNumberPattern>\d{11}</possibleNumberPattern>
+ <exampleNumber>65816123456</exampleNumber>
+ </voicemail>
<shortCode>
<nationalNumberPattern>
1(?:
<mobile>
<!-- Added 66, 67 and 68 as prefixes because of online numbers fitting this pattern. It
seems that 88-0xx is also being used, for 9-digit long numbers, and that some numbers
- beginning with 776 are also 9 digits long now. -->
+ beginning with 77[67] are also 9 digits long now. -->
<nationalNumberPattern>
(?:
4[67]|
5\d|
6[4-8]|
7(?:
- 76\d|
+ 7[67]\d|
\d{2}
)|
880\d
<!-- Myanmar -->
<!-- http://www.itu.int/oth/T0202000092/en -->
- <territory id="MM" countryCode="95" internationalPrefix="00">
+ <territory id="MM" countryCode="95" internationalPrefix="00" nationalPrefix="0"
+ nationalPrefixFormattingRule="$NP$FG">
<availableFormats>
<numberFormat pattern="(1)(\d{3})(\d{3})">
<leadingDigits>1</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
- <!-- This overlaps the previous pattern. -->
+ <!-- This overlaps with the previous pattern. -->
<numberFormat pattern="(1)(3)(33\d)(\d{3})">
<leadingDigits>133</leadingDigits>
<leadingDigits>1333</leadingDigits>
<leadingDigits>2</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
+ <numberFormat pattern="(\d{2})(\d{3})(\d{3})">
+ <leadingDigits>
+ 67|
+ 81
+ </leadingDigits>
+ <format>$1 $2 $3</format>
+ </numberFormat>
<numberFormat pattern="(\d{2})(\d{2})(\d{3})">
<leadingDigits>[4-8]</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
- <!-- Format is from http://www.aitaa.ait.ac.th/chapters/copy17_of_aitaa-national-chapters-1 -->
- <numberFormat pattern="(9444)(\d{5})">
- <leadingDigits>94</leadingDigits>
- <format>$1 $2</format>
- </numberFormat>
- <numberFormat pattern="(9)([25689]\d{2})(\d{4})">
- <leadingDigits>9[25689]</leadingDigits>
+ <numberFormat pattern="(9)(\d{3})(\d{4,5})">
+ <leadingDigits>9[24-9]</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>
[124-8]\d{5,7}|
- 9\d{7,8}
+ 9(?:
+ [25689]|
+ [47]\d
+ )\d{6}
</nationalNumberPattern>
<possibleNumberPattern>\d{5,9}</possibleNumberPattern>
</generalDesc>
<fixedLine>
- <!-- Fixed satellite network numbers (1 3 33X XXX) are also included here. -->
+ <!-- Fixed satellite network numbers (1 3 33X XXX) are also included here. It seems as well
+ that numbers starting with 081 may be followed by six digits, as well as five, so we
+ support both. -->
<nationalNumberPattern>
(?:
1\d|
2|
4[2-6]|
5[2-9]|
- 6\d|
+ 6(?:
+ [0-689]|
+ 7\d?
+ )|
7[0-5]|
- 8[1-6]
+ 8(?:
+ [2-6]|
+ 1\d?
+ )
)\d{5}|
1333\d{4}
</nationalNumberPattern>
<exampleNumber>1234567</exampleNumber>
</fixedLine>
<mobile>
+ <!-- Mobile numbers starting with 09 7XX and 09 4XX have been found online, despite not
+ being in the plan, so we support these here.-->
<nationalNumberPattern>
9(?:
- [25689]\d|
- 444
- )\d{5}
+ [25689]|
+ [47]\d
+ )\d{6}
</nationalNumberPattern>
<possibleNumberPattern>\d{8,9}</possibleNumberPattern>
<exampleNumber>92123456</exampleNumber>
<possibleNumberPattern>\d{10,14}</possibleNumberPattern>
<exampleNumber>80017591759</exampleNumber>
</tollFree>
- <personalNumber>
+ <uan>
<nationalNumberPattern>700\d{7,11}</nationalNumberPattern>
<possibleNumberPattern>\d{10,14}</possibleNumberPattern>
<exampleNumber>7001234567</exampleNumber>
- </personalNumber>
+ </uan>
<emergency>
<nationalNumberPattern>199</nationalNumberPattern>
<possibleNumberPattern>\d{3}</possibleNumberPattern>
</numberFormat>
</availableFormats>
<generalDesc>
- <nationalNumberPattern>[1-9]\d{7,10}</nationalNumberPattern>
+ <!-- The more detailed pattern here is to allow the country-code to be stripped off for
+ fixed-line numbers. -->
+ <nationalNumberPattern>
+ [1-467]\d{7}|
+ 5\d{8}|
+ (?:
+ 8|
+ 92
+ )\d{9}
+ </nationalNumberPattern>
<possibleNumberPattern>\d{7,11}</possibleNumberPattern>
</generalDesc>
<fixedLine>
preferredInternationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{3})">
- <leadingDigits>
- [35789]|
- 2[1-4689]|
- 6[0-35-9]
- </leadingDigits>
+ <leadingDigits>[89]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d)(\d{3})(\d{3})">
- <leadingDigits>
- 2[57]|
- 4|
- 64
- </leadingDigits>
+ <leadingDigits>[246]</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
</availableFormats>
<generalDesc>
- <nationalNumberPattern>[2-9]\d{5,6}</nationalNumberPattern>
+ <nationalNumberPattern>[24689]\d{5,6}</nationalNumberPattern>
<possibleNumberPattern>\d{6,7}</possibleNumberPattern>
</generalDesc>
<fixedLine>
cannot find any evidence that they are more expensive to call than other Fixed Line
services. ISDN and DID services are here too, since they seem to be also fixed-line
phone numbers. -->
- <!-- Old numbers and new numbers (with 4 at front) running in parallel from 4th May
- 2011 until 4 August 2011. Note the 55 and 78 numbers will have a 2 inserted at
- front instead of a 4.
- Since the 4 is optional, the new group 44\d{5} that have been assigned have been
- separated out in the reg-exp for now to prevent 4\d{5} being considered valid. -->
<nationalNumberPattern>
(?:
- 2?(?:
+ 2(?:
55[0-5]|
78[013]
)|
- 4?(?:
+ 4(?:
2(?:
0[589]|
1[03-9]|
[2-9]\d
)|
- [36]\d{2}
- )|
- 44\d{2}
+ [346]\d{2}
+ )
)\d{3}
</nationalNumberPattern>
- <possibleNumberPattern>\d{6,7}</possibleNumberPattern>
+ <possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>4217123</exampleNumber>
</fixedLine>
<mobile>
- <!-- Old and new numbers (with an 2 at the front) running in parallel from 4th May 2011
- to 4 August 2011. -->
<nationalNumberPattern>
- 2?(?:
+ 2(?:
5(?:
[0-46-9]\d|
5[6-9]
)
)\d{3}
</nationalNumberPattern>
- <possibleNumberPattern>\d{6,7}</possibleNumberPattern>
+ <possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>2510123</exampleNumber>
</mobile>
<tollFree>
<possibleNumberPattern>\d{7,9}</possibleNumberPattern>
</generalDesc>
<fixedLine>
+ <!-- Adding 711 from numbers found online, such as the US embassy. -->
<nationalNumberPattern>
(?:
6(?:
7[12456]|
9[135-8]
)|
- 12\d|
+ 1[12]\d|
2(?:
22|
3[1345789]|
required PhoneNumberDesc pager = 21;
required PhoneNumberDesc uan = 25;
required PhoneNumberDesc emergency = 27;
+ required PhoneNumberDesc voicemail = 28;
// The rules here distinguish the numbers that are only able to be dialled
// nationally.
required PhoneNumberDesc no_international_dialling = 24;
private static final String SHARED_COST = "sharedCost";
private static final String TOLL_FREE = "tollFree";
private static final String UAN = "uan";
+ private static final String VOICEMAIL = "voicemail";
private static final String VOIP = "voip";
// @VisibleForTesting
PERSONAL_NUMBER));
metadata.setPager(processPhoneNumberDescElement(generalDesc, element, PAGER));
metadata.setUan(processPhoneNumberDescElement(generalDesc, element, UAN));
+ metadata.setVoicemail(processPhoneNumberDescElement(generalDesc, element, VOICEMAIL));
metadata.setEmergency(processPhoneNumberDescElement(generalDesc, element, EMERGENCY));
metadata.setNoInternationalDialling(processPhoneNumberDescElement(generalDesc, element,
NO_INTERNATIONAL_DIALLING));