Browse Source

JAVA: libphonenumber v3.3.

pull/567/head
Shaopeng Jia 15 years ago
committed by Mihaela Rosca
parent
commit
3f782e75b8
37 changed files with 549 additions and 175 deletions
  1. +10
    -0
      java/release_notes.txt
  2. +25
    -8
      java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java
  3. +41
    -44
      java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java
  4. +32
    -31
      java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  5. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM
  6. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ
  7. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF
  8. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BW
  9. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ
  10. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CI
  11. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR
  12. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FJ
  13. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FM
  14. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GB
  15. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GP
  16. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY
  17. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK
  18. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM
  19. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH
  20. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB
  21. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LY
  22. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MV
  23. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NF
  24. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NI
  25. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NR
  26. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PE
  27. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PK
  28. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SZ
  29. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TJ
  30. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TV
  31. BIN
      java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US
  32. +1
    -1
      java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java
  33. +25
    -1
      java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java
  34. +4
    -4
      java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  35. BIN
      java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_JP
  36. +405
    -86
      resources/PhoneNumberMetaData.xml
  37. +6
    -0
      resources/PhoneNumberMetaDataForTesting.xml

+ 10
- 0
java/release_notes.txt View File

@ -1,3 +1,13 @@
Apr 26th, 2011
* Code changes:
- Improved PhoneNumberMatcher for cases with other numbers before or after the phone number.
- Improved AsYouTypeFormatter not to use formatting rules containing non-formatting characters
(e.g. '*' in Israeli star numbers).
* Metadata changes:
- New countries: FJ, FM, GY, NF, NI, NR, TV.
- Updates: AM, AZ, BF, BW, BZ, CI, CR, GB, GP, HK, JM, KH, LB, LY, MV, PE, PK, SZ, TJ, US.
* Minor documentation updates
Apr 11th, 2011
* Bug fixes:
- Adding date exclusion pattern in PhoneNumberMatcher.


+ 25
- 8
java/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java View File

@ -28,11 +28,11 @@ import java.util.regex.Pattern;
/**
* A formatter which formats phone numbers as they are entered.
*
* <p>An AsYouTypeFormatter could be created by invoking
* {@link PhoneNumberUtil#getAsYouTypeFormatter}. After that digits could be added by invoking
* <p>An AsYouTypeFormatter can be created by invoking
* {@link PhoneNumberUtil#getAsYouTypeFormatter}. After that, digits can be added by invoking
* {@link #inputDigit} on the formatter instance, and the partially formatted phone number will be
* returned each time a digit is added. {@link #clear} could be invoked before a new number needs to
* be formatted.
* returned each time a digit is added. {@link #clear} can be invoked before formatting a new
* number.
*
* <p>See the unittests for more details on how the formatter is to be used.
*
@ -66,6 +66,15 @@ public class AsYouTypeFormatter {
// the phone number can be as long as 15 digits.
private static final Pattern STANDALONE_DIGIT_PATTERN = Pattern.compile("\\d(?=[^,}][^,}])");
// A pattern that is used to determine if a numberFormat under availableFormats is eligible to be
// used by the AYTF. It is eligible when the format element under numberFormat contains groups of
// the dollar sign followed by a single digit, separated by valid phone number punctuation. This
// prevents invalid punctuation (such as the star sign in Israeli star numbers) getting into the
// output of the AYTF.
private static final Pattern ELIGIBLE_FORMAT_PATTERN =
Pattern.compile("[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*" +
"(\\$\\d" + "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]*)+");
// This is the minimum length of national number accrued that is required to trigger the
// formatter. The first element of the leadingDigitsPattern of each numberFormat contains a
// regular expression that matches up to this number of digits.
@ -134,10 +143,18 @@ public class AsYouTypeFormatter {
(isInternationalFormatting && currentMetaData.intlNumberFormatSize() > 0)
? currentMetaData.intlNumberFormats()
: currentMetaData.numberFormats();
possibleFormats.addAll(formatList);
for (NumberFormat format : formatList) {
if (isFormatEligible(format.getFormat())) {
possibleFormats.add(format);
}
}
narrowDownPossibleFormats(leadingThreeDigits);
}
private boolean isFormatEligible(String format) {
return ELIGIBLE_FORMAT_PATTERN.matcher(format).matches();
}
private void narrowDownPossibleFormats(String leadingDigits) {
int indexOfLeadingDigitsPattern = leadingDigits.length() - MIN_LEADING_DIGITS_LENGTH;
Iterator<NumberFormat> it = possibleFormats.iterator();
@ -179,7 +196,7 @@ public class AsYouTypeFormatter {
return false;
}
// Gets a formatting template which could be used to efficiently format a partial number where
// Gets a formatting template which can be used to efficiently format a partial number where
// digits are added one by one.
private String getFormattingTemplate(String numberPattern, String numberFormat) {
// Creates a phone number consisting only of the digit 9 that matches the
@ -196,7 +213,7 @@ public class AsYouTypeFormatter {
}
/**
* Clears the internal state of the formatter, so it could be reused.
* Clears the internal state of the formatter, so it can be reused.
*/
public void clear() {
currentOutput = "";
@ -234,7 +251,7 @@ public class AsYouTypeFormatter {
/**
* Same as {@link #inputDigit}, but remembers the position where {@code nextChar} is inserted, so
* that it could be retrieved later by using {@link #getRememberedPosition}. The remembered
* that it can be retrieved later by using {@link #getRememberedPosition}. The remembered
* position will be automatically adjusted if additional formatting characters are later
* inserted/removed in front of {@code nextChar}.
*/


+ 41
- 44
java/src/com/google/i18n/phonenumbers/PhoneNumberMatcher.java View File

@ -53,12 +53,6 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
* </ul>
*/
private static final Pattern PATTERN;
/**
* A phone number pattern that does not allow whitespace as punctuation. This pattern is only used
* in a second attempt to find a phone number occurring in the context of other numbers, such as
* when the preceding or following token is a zip code.
*/
private static final Pattern INNER;
/**
* Matches strings that look like publication pages. Example:
* <pre>Computing Complete Answers to Queries in the Presence of Limited Access Patterns.
@ -75,9 +69,15 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
private static final Pattern SLASH_SEPARATED_DATES =
Pattern.compile("(?:(?:[0-3]?\\d/[01]?\\d)|(?:[01]?\\d/[0-3]?\\d))/(?:[12]\\d)?\\d{2}");
/**
* Matches white-space, which may indicate the end of a phone number and the start of something
* else (such as a neighbouring zip-code).
*/
private static final Pattern GROUP_SEPARATOR = Pattern.compile("\\p{Z}+");
static {
/* Builds the PATTERN and INNER regular expression patterns. The building blocks below
* exist to make the patterns more easily understood. */
/* Builds the PATTERN regular expression. The building blocks below exist to make the pattern
* more easily understood. */
/* Limit on the number of leading (plus) characters. */
String leadLimit = limit(0, 2);
@ -92,10 +92,6 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
* formats use spaces to separate each digit. */
String blockLimit = limit(0, digitBlockLimit);
/* Same as {@link PhoneNumberUtil#VALID_PUNCTUATION} but without space characters. */
String nonSpacePunctuationChars = removeSpace(PhoneNumberUtil.VALID_PUNCTUATION);
/* A punctuation sequence without white space. */
String nonSpacePunctuation = "[" + nonSpacePunctuationChars + "]" + punctuationLimit;
/* A punctuation sequence allowing white space. */
String punctuation = "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]" + punctuationLimit;
/* A digits block without punctuation. */
@ -109,12 +105,6 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
digitSequence + "(?:" + punctuation + digitSequence + ")" + blockLimit +
"(?:" + PhoneNumberUtil.KNOWN_EXTN_PATTERNS + ")?",
PhoneNumberUtil.REGEX_FLAGS);
/* Phone number pattern with no whitespace allowed. */
INNER = Pattern.compile(
leadClass + leadLimit +
digitSequence + "(?:" + nonSpacePunctuation + digitSequence + ")" + blockLimit,
PhoneNumberUtil.REGEX_FLAGS);
}
/** Returns a regular expression quantifier with an upper and lower limit. */
@ -125,23 +115,6 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
return "{" + lower + "," + upper + "}";
}
/**
* Returns a copy of {@code characters} with any {@linkplain Character#isSpaceChar space}
* characters removed.
*/
private static String removeSpace(String characters) {
StringBuilder builder = new StringBuilder(characters.length());
int i = 0;
while (i < characters.length()) {
int codePoint = characters.codePointAt(i);
if (!Character.isSpaceChar(codePoint)) {
builder.appendCodePoint(codePoint);
}
i += Character.charCount(codePoint);
}
return builder.toString();
}
/** The potential states of a PhoneNumberMatcher. */
private enum State {
NOT_READY, READY, DONE
@ -287,28 +260,52 @@ final class PhoneNumberMatcher implements Iterator<PhoneNumberMatch> {
return match;
}
// If that failed, try to find an inner match without white space.
// If that failed, try to find an "inner match" - there might be a phone number within this
// candidate.
return extractInnerMatch(rawString, offset);
}
/**
* Attempts to extract a match from {@code candidate} using the {@link #INNER} pattern.
* Attempts to extract a match from {@code candidate} if the whole candidate does not qualify as a
* match.
*
* @param candidate the candidate text that might contain a phone number
* @param offset the offset of {@code candidate} within {@link #text}
* @param offset the current offset of {@code candidate} within {@link #text}
* @return the match found, null if none can be found
*/
private PhoneNumberMatch extractInnerMatch(String candidate, int offset) {
int index = 0;
Matcher matcher = INNER.matcher(candidate);
while ((maxTries > 0) && matcher.find(index)) {
String innerCandidate = candidate.substring(matcher.start(), matcher.end());
PhoneNumberMatch match = parseAndVerify(innerCandidate, offset + matcher.start());
// Try removing either the first or last "group" in the number and see if this gives a result.
// We consider white space to be a possible indications of the start or end of the phone number.
Matcher groupMatcher = GROUP_SEPARATOR.matcher(candidate);
if (groupMatcher.find()) {
int groupStartIndex = groupMatcher.end();
// Remove the first group.
CharSequence withoutFirstGroup = candidate.substring(groupStartIndex);
withoutFirstGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
withoutFirstGroup);
PhoneNumberMatch match = parseAndVerify(withoutFirstGroup.toString(),
offset + groupStartIndex);
if (match != null) {
return match;
}
maxTries--;
index = matcher.end();
if (maxTries > 0) {
int lastGroupStart = groupStartIndex;
while (groupMatcher.find()) {
// Find the last group.
lastGroupStart = groupMatcher.start();
}
CharSequence withoutLastGroup = candidate.substring(0, lastGroupStart);
withoutLastGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
withoutLastGroup);
match = parseAndVerify(withoutLastGroup.toString(), offset);
if (match != null) {
return match;
}
maxTries--;
}
}
return null;
}


+ 32
- 31
java/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -104,7 +104,8 @@ public class PhoneNumberUtil {
private static final Map<Character, Character> ALL_PLUS_NUMBER_GROUPING_SYMBOLS;
static {
// Simple ASCII digits map used to populate DIGIT_MAPPINGS and ALPHA_MAPPINGS.
// Simple ASCII digits map used to populate DIGIT_MAPPINGS and
// ALL_PLUS_NUMBER_GROUPING_SYMBOLS.
HashMap<Character, Character> asciiDigitMappings = new HashMap<Character, Character>();
asciiDigitMappings.put('0', '0');
asciiDigitMappings.put('1', '1');
@ -263,7 +264,7 @@ public class PhoneNumberUtil {
// are not alpha or numerical characters. The hash character is retained here, as it may signify
// the previous block was an extension.
private static final String UNWANTED_END_CHARS = "[[\\P{N}&&\\P{L}]&&[^#]]+$";
private static final Pattern UNWANTED_END_CHAR_PATTERN = Pattern.compile(UNWANTED_END_CHARS);
static final Pattern UNWANTED_END_CHAR_PATTERN = Pattern.compile(UNWANTED_END_CHARS);
// We use this pattern to check if the phone number has at least three letters in it - if so, then
// we treat it as a number where some phone-number digits are represented by letters.
@ -466,13 +467,13 @@ public class PhoneNumberUtil {
/**
* Attempts to extract a possible number from the string passed in. This currently strips all
* leading characters that could not be used to start a phone number. Characters that can be used
* to start a phone number are defined in the VALID_START_CHAR_PATTERN. If none of these
* characters are found in the number passed in, an empty string is returned. This function also
* attempts to strip off any alternative extensions or endings if two or more are present, such as
* in the case of: (530) 583-6985 x302/x2303. The second extension here makes this actually two
* phone numbers, (530) 583-6985 x302 and (530) 583-6985 x2303. We remove the second extension so
* that the first number is parsed correctly.
* leading characters that cannot be used to start a phone number. Characters that can be used to
* start a phone number are defined in the VALID_START_CHAR_PATTERN. If none of these characters
* are found in the number passed in, an empty string is returned. This function also attempts to
* strip off any alternative extensions or endings if two or more are present, such as in the case
* of: (530) 583-6985 x302/x2303. The second extension here makes this actually two phone numbers,
* (530) 583-6985 x302 and (530) 583-6985 x2303. We remove the second extension so that the first
* number is parsed correctly.
*
* @param number the string that might contain a phone number
* @return the number, stripped of any non-phone-number prefix (such as "Tel:") or an empty
@ -960,7 +961,7 @@ public class PhoneNumberUtil {
}
/**
* Formats a phone number for out-of-country dialing purposes. If no countryCallingFrom is
* Formats a phone number for out-of-country dialing purposes. If no regionCallingFrom is
* supplied, we format the number in its INTERNATIONAL format. If the country calling code is the
* same as the region where the number is from, then NATIONAL formatting will be applied.
*
@ -1624,14 +1625,14 @@ public class PhoneNumberUtil {
* significant number could contain a leading zero. An example of such a region is Italy. Returns
* false if no metadata for the country is found.
*/
boolean isLeadingZeroPossible(int countryCallingCode) {
PhoneMetadata mainMetadataForCallingCode = getMetadataForRegion(
getRegionCodeForCountryCode(countryCallingCode));
if (mainMetadataForCallingCode == null) {
return false;
}
return mainMetadataForCallingCode.isLeadingZeroPossible();
}
boolean isLeadingZeroPossible(int countryCallingCode) {
PhoneMetadata mainMetadataForCallingCode = getMetadataForRegion(
getRegionCodeForCountryCode(countryCallingCode));
if (mainMetadataForCallingCode == null) {
return false;
}
return mainMetadataForCallingCode.isLeadingZeroPossible();
}
/**
* Checks if the number is a valid vanity (alpha) number such as 800 MICROSOFT. A valid vanity
@ -1742,12 +1743,12 @@ public class PhoneNumberUtil {
* @param number the number that needs to be checked, in the form of a string
* @param regionDialingFrom the ISO 3166-1 two-letter region code that denotes the region that
* we are expecting the number to be dialed from.
* Note this is different from the region where the number belongs. For example, the number
* +1 650 253 0000 is a number that belongs to US. When written in this form, it could be
* dialed from any region. When it is written as 00 1 650 253 0000, it could be dialed from
* any region which uses an international dialling prefix of 00. When it is written as 650
* 253 0000, it could only be dialed from within the US, and when written as 253 0000, it
* could only be dialed from within a smaller area in the US (Mountain View, CA, to be more
* Note this is different from the region where the number belongs. For example, the number
* +1 650 253 0000 is a number that belongs to US. When written in this form, it can be
* dialed from any region. When it is written as 00 1 650 253 0000, it can be dialed from any
* region which uses an international dialling prefix of 00. When it is written as
* 650 253 0000, it can only be dialed from within the US, and when written as 253 0000, it
* can only be dialed from within a smaller area in the US (Mountain View, CA, to be more
* specific).
* @return true if the number is possible
*/
@ -1791,7 +1792,7 @@ public class PhoneNumberUtil {
* @param regionCode the ISO 3166-1 two-letter region code that denotes the region where
* the phone number is being entered
*
* @return an {@link com.google.i18n.phonenumbers.AsYouTypeFormatter} object, which could be used
* @return an {@link com.google.i18n.phonenumbers.AsYouTypeFormatter} object, which can be used
* to format phone numbers in the specific region "as you type"
*/
public AsYouTypeFormatter getAsYouTypeFormatter(String regionCode) {
@ -1898,8 +1899,8 @@ public class PhoneNumberUtil {
Pattern possibleNumberPattern =
regexCache.getPatternForRegex(generalDesc.getPossibleNumberPattern());
// If the number was not valid before but is valid now, or if it was too long before, we
// consider the number with the country code stripped to be a better result and keep that
// instead.
// consider the number with the country calling code stripped to be a better result and
// keep that instead.
if ((!validNumberPattern.matcher(fullNumber).matches() &&
validNumberPattern.matcher(potentialNationalNumber).matches()) ||
testNumberLengthAgainstPattern(possibleNumberPattern, fullNumber.toString())
@ -1950,8 +1951,8 @@ public class PhoneNumberUtil {
* @param possibleIddPrefix the international direct dialing prefix from the region we
* think this number may be dialed in
* @return the corresponding CountryCodeSource if an international dialing prefix could be
* removed from the number, otherwise CountryCodeSource.FROM_DEFAULT_COUNTRY if the
* number did not seem to be in international format.
* removed from the number, otherwise CountryCodeSource.FROM_DEFAULT_COUNTRY if the number did
* not seem to be in international format.
*/
CountryCodeSource maybeStripInternationalPrefixAndNormalize(
StringBuffer number,
@ -2371,7 +2372,7 @@ public class PhoneNumberUtil {
* @param firstNumber first number to compare. Can contain formatting, and can have country
* calling code specified with + at the start.
* @param secondNumber second number to compare. Can contain formatting, and can have country
* code specified with + at the start.
* calling code specified with + at the start.
* @return NOT_A_NUMBER, NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH, EXACT_MATCH. See
* isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber) for more details.
*/
@ -2409,7 +2410,7 @@ public class PhoneNumberUtil {
*
* @param firstNumber first number to compare in proto buffer format.
* @param secondNumber second number to compare. Can contain formatting, and can have country
* code specified with + at the start.
* calling code specified with + at the start.
* @return NOT_A_NUMBER, NO_MATCH, SHORT_NSN_MATCH, NSN_MATCH, EXACT_MATCH. See
* isNumberMatch(PhoneNumber firstNumber, PhoneNumber secondNumber) for more details.
*/


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AM View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_AZ View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BF View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BW View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_BZ View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CI View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_CR View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FJ View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_FM View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GB View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GP View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_GY View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_HK View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_JM View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KH View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LB View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LY View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MV View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NF View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NI View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NR View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PE View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PK View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SZ View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TJ View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TV View File


BIN
java/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US View File


+ 1
- 1
java/test/com/google/i18n/phonenumbers/AsYouTypeFormatterTest.java View File

@ -343,7 +343,7 @@ public class AsYouTypeFormatterTest extends TestCase {
}
public void testAYTFGBTollFree() {
AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter("gb");
AsYouTypeFormatter formatter = phoneUtil.getAsYouTypeFormatter("gb");
assertEquals("0", formatter.inputDigit('0'));
assertEquals("08", formatter.inputDigit('8'));
assertEquals("080", formatter.inputDigit('0'));


+ 25
- 1
java/test/com/google/i18n/phonenumbers/PhoneNumberMatcherTest.java View File

@ -198,6 +198,30 @@ public class PhoneNumberMatcherTest extends TestCase {
}
}
public void testMatchWithSurroundingZipcodes() throws Exception {
String number = "415-666-7777";
String zipPreceding = "My address is CA 34215. " + number + " is my number.";
PhoneNumber expectedResult = phoneUtil.parse(number, "US");
Iterator<PhoneNumberMatch> iterator = phoneUtil.findNumbers(zipPreceding, "US").iterator();
PhoneNumberMatch match = iterator.hasNext() ? iterator.next() : null;
assertNotNull("Did not find a number in '" + zipPreceding + "'; expected " + number, match);
assertEquals(expectedResult, match.number());
assertEquals(number, match.rawString());
// Now repeat, but this time the phone number has spaces in it. It should still be found.
number = "(415) 666 7777";
String zipFollowing = "My number is " + number + ". 34215 is my zip-code.";
iterator = phoneUtil.findNumbers(zipFollowing, "US").iterator();
PhoneNumberMatch matchWithSpaces = iterator.hasNext() ? iterator.next() : null;
assertNotNull("Did not find a number in '" + zipFollowing + "'; expected " + number,
matchWithSpaces);
assertEquals(expectedResult, matchWithSpaces.number());
assertEquals(number, matchWithSpaces.rawString());
}
public void testNoMatchIfRegionIsNull() throws Exception {
// Fail on non-international prefix if region code is null.
assertTrue(hasNoMatches(phoneUtil.findNumbers(
@ -417,7 +441,7 @@ public class PhoneNumberMatcherTest extends TestCase {
}
/**
* Tests numbers found by {@link PhoneNumberUtil#find(CharSequence, String)} in various
* Tests numbers found by {@link PhoneNumberUtil#findNumbers(CharSequence, String)} in various
* textual contexts.
*
* @param number the number to test and the corresponding region code to use


+ 4
- 4
java/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java View File

@ -372,6 +372,7 @@ public class PhoneNumberUtilTest extends TestCase {
assertEquals("1234", phoneUtil.format(DE_SHORT_NUMBER, PhoneNumberFormat.NATIONAL));
assertEquals("+49 1234", phoneUtil.format(DE_SHORT_NUMBER, PhoneNumberFormat.INTERNATIONAL));
deNumber.clear();
deNumber.setCountryCode(49).setNationalNumber(41341234);
assertEquals("04134 1234", phoneUtil.format(deNumber, PhoneNumberFormat.NATIONAL));
}
@ -719,12 +720,11 @@ public class PhoneNumberUtilTest extends TestCase {
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(BS_MOBILE));
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(GB_MOBILE));
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(IT_MOBILE));
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(AR_MOBILE));
PhoneNumber mobileNumber = new PhoneNumber();
mobileNumber.setCountryCode(49).setNationalNumber(15123456789L);
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(mobileNumber));
assertEquals(PhoneNumberUtil.PhoneNumberType.MOBILE, phoneUtil.getNumberType(AR_MOBILE));
}
public void testIsFixedLine() {
@ -913,8 +913,8 @@ public class PhoneNumberUtilTest extends TestCase {
assertEquals(PhoneNumberUtil.ValidationResult.TOO_SHORT,
phoneUtil.isPossibleNumberWithReason(number));
number.setCountryCode(65);
number.setNationalNumber(1234567890L);
number.clear();
number.setCountryCode(65).setNationalNumber(1234567890L);
assertEquals(PhoneNumberUtil.ValidationResult.IS_POSSIBLE,
phoneUtil.isPossibleNumberWithReason(number));


BIN
java/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_JP View File


+ 405
- 86
resources/PhoneNumberMetaData.xml View File

@ -514,10 +514,15 @@
<numberFormat pattern="(\d{2})(\d{6})">
<leadingDigits>
[17]|
9[1-469]
9[1-9]
</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{2})(\d{6})"
nationalPrefixFormattingRule="$NP$FG">
<leadingDigits>6</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{3})(\d{5})">
<leadingDigits>[23]</leadingDigits>
<format>$1 $2</format>
@ -532,7 +537,7 @@
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[1-37-9]\d{7}</nationalNumberPattern>
<nationalNumberPattern>[1-36-9]\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{5,8}</possibleNumberPattern>
</generalDesc>
<fixedLine>
@ -556,7 +561,7 @@
<nationalNumberPattern>
(?:
77|
9[1-469]
9[1-46-9]
)\d{6}
</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
@ -577,6 +582,12 @@
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>80112345</exampleNumber>
</sharedCost>
<voip>
<!-- More info on this found at www.arminco.com/en/voip -->
<nationalNumberPattern>6027\d{4}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>60271234</exampleNumber>
</voip>
<shortCode>
<nationalNumberPattern>
8[1-7]\d{2}|
@ -1359,9 +1370,14 @@
<leadingDigits>[4-8]</leadingDigits>
<format>$1 $2 $3 $4</format>
</numberFormat>
<numberFormat pattern="(\d{3})(\d{2})(\d{2})(\d{2})"
nationalPrefixFormattingRule="$NP$FG">
<leadingDigits>9</leadingDigits>
<format>$1 $2 $3 $4</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[1-8]\d{7,8}</nationalNumberPattern>
<nationalNumberPattern>[1-9]\d{7,8}</nationalNumberPattern>
<possibleNumberPattern>\d{5,9}</possibleNumberPattern>
</generalDesc>
<fixedLine>
@ -1410,10 +1426,18 @@
<exampleNumber>401234567</exampleNumber>
</mobile>
<tollFree>
<!-- 88 is listed as fixed-line for Baku in the ITU document, but online numbers seem to
suggest they are in fact national toll-free numbers. -->
<nationalNumberPattern>88\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>881234567</exampleNumber>
</tollFree>
<premiumRate>
<!-- These are marked as Interactive Calls in the ITU document. -->
<nationalNumberPattern>900200\d{3}</nationalNumberPattern>
<possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>900200123</exampleNumber>
</premiumRate>
</territory>
<!-- Bosnia and Herzegovina -->
@ -1849,12 +1873,13 @@
</fixedLine>
<mobile>
<!-- Including the whole range of 75 despite the document restricting it to only a few,
since even the Zain help-line is outside the range that the document specifies. -->
since diallable numbers have been found outside the range that the document specifies.
Including 716 as well since many numbers seem to have this prefix. -->
<nationalNumberPattern>
7(?:
[024-6]\d|
1[0-489]|
3[0124]|
1[0-4689]|
3[0-6]|
7[01]|
8[013-9]|
9[0-4]
@ -2549,10 +2574,14 @@
</territory>
<!-- Botswana -->
<!-- http://www.itu.int/dms_pub/itu-t/oth/02/02/T020200001C0001MSWE.doc -->
<!-- http://www.itu.int/oth/T020200001C/en -->
<territory id="BW" countryCode="267" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(7[1-4])(\d{3})(\d{3})">
<numberFormat pattern="(\d{3})(\d{4})">
<leadingDigits>[2-6]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(7\d)(\d{3})(\d{3})">
<leadingDigits>7</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
@ -2562,7 +2591,7 @@
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[2-9]\d{6,7}</nationalNumberPattern>
<nationalNumberPattern>[2-79]\d{6,7}</nationalNumberPattern>
<possibleNumberPattern>\d{7,8}</possibleNumberPattern>
</generalDesc>
<fixedLine>
@ -2605,23 +2634,26 @@
<mobile>
<nationalNumberPattern>
7(?:
[1-3]\d{6}|
4[0-7]\d{5}
[1-35]\d{6}|
[46][0-7]\d{5}
)
</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>71123456</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>8\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>8123456</exampleNumber>
</tollFree>
<!-- No reliable information about toll-free numbers can be found; many are written on the
internet like 0800 123 456, but this is not supported by any documentation and no
numbers can be found that actually work. -->
<premiumRate>
<nationalNumberPattern>90\d{5}</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>9012345</exampleNumber>
</premiumRate>
<voip>
<nationalNumberPattern>79[12][01]\d{4}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>79101234</exampleNumber>
</voip>
</territory>
<!-- Belarus -->
@ -2745,11 +2777,12 @@
<exampleNumber>2221234</exampleNumber>
</fixedLine>
<mobile>
<!-- 62[6-9] were added as we have been able to successfully send SMSs to these numbers. -->
<nationalNumberPattern>
6(?:
[01]\d|
2[0-5]|
[67][01])\d{4}
[0-2]\d|
[67][01]
)\d{4}
</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>6221234</exampleNumber>
@ -3087,13 +3120,13 @@
<exampleNumber>21234567</exampleNumber>
</fixedLine>
<mobile>
<!-- Added the prefix 40 because SMS messages have been successfully delivered. Supported by
numbers found on the internet. -->
<!-- Added the prefixes 40 and 57 because SMS messages have been successfully delivered.
Supported by numbers found on the internet. -->
<nationalNumberPattern>
(?:
0[1-9]|
4[04-9]|
50|
5[07]|
6[067]
)\d{6}
</nationalNumberPattern>
@ -3854,7 +3887,7 @@
<numberFormat pattern="(\d{4})(\d{4})">
<leadingDigits>
[24]|
8[389]
8[3-9]
</leadingDigits>
<format>$1 $2</format>
</numberFormat>
@ -3873,7 +3906,14 @@
<exampleNumber>22123456</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>8[389]\d{6}</nationalNumberPattern>
<!-- Adding 87[0-3] prefixes after numbers were found online where these prefixes have been
assigned. -->
<nationalNumberPattern>
8(?:
[389]\d|
7[0-3]
)\d{5}
</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>83123456</exampleNumber>
</mobile>
@ -5233,7 +5273,79 @@
</territory>
<!-- Fiji -->
<territory id="FJ" countryCode="679" internationalPrefix="00">
<!-- http://www.itu.int/oth/T0202000048/en -->
<!-- www.tfl.com.fj -->
<territory id="FJ" countryCode="679" internationalPrefix="0(?:0|52)"
preferredInternationalPrefix="00" leadingZeroPossible="true">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<leadingDigits>[36-9]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{4})(\d{3})(\d{4})">
<leadingDigits>0</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>
[36-9]\d{6}|
0\d{10}
</nationalNumberPattern>
<possibleNumberPattern>\d{7}(?:\d{4})?</possibleNumberPattern>
</generalDesc>
<fixedLine>
<!-- Adding the prefixes 30X, 31X and 62X, since numbers with these prefixes have been found
online, including in the white pages. 35X and 85X were found in the exchanges listed on
www.tfl.com.fj. -->
<nationalNumberPattern>
(?:
3[0-5]|
6[25-7]|
8[58]
)\d{5}
</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>3212345</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>
(?:
7[0-4]|
9[29]
)\d{5}
</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
<exampleNumber>7012345</exampleNumber>
</mobile>
<tollFree>
<!-- Information found on www.tfl.com.fj. It is not clear if these are internationally
diallable, or if so, how. -->
<nationalNumberPattern>0800\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{11}</possibleNumberPattern>
<exampleNumber>08001234567</exampleNumber>
</tollFree>
<shortCode>
<!-- From the Emergency Numbers page on the Telecom Fiji website. -->
<nationalNumberPattern>
0(?:
04|
1[34]|
8[1-4]
)|
1(?:
0[1-3]|
[25]9
)|
2[289]|
30|
[45]4|
75|
91[137]
</nationalNumberPattern>
<possibleNumberPattern>\d{2,3}</possibleNumberPattern>
<exampleNumber>22</exampleNumber>
</shortCode>
</territory>
<!-- Falkland Islands (Malvinas) -->
@ -5263,7 +5375,33 @@
</territory>
<!-- Micronesia, Federated States of -->
<!-- http://www.itu.int/oth/T020200008B/en -->
<territory id="FM" countryCode="691" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[39]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>
3[2357]0[1-9]\d{3}|
9[2-6]\d{5}
</nationalNumberPattern>
<exampleNumber>3201234</exampleNumber>
</fixedLine>
<mobile>
<!-- Note that most ranges are used for both fixed and mobile but numbers starting with 970
are exclusively mobile. -->
<nationalNumberPattern>
3[2357]0[1-9]\d{3}|
9[2-7]\d{5}
</nationalNumberPattern>
<exampleNumber>3501234</exampleNumber>
</mobile>
</territory>
<!-- Faroe Islands -->
@ -5942,7 +6080,7 @@
9(?:
[04-9]\d|
1[02-9]|
2[0135-9]|
2[0-35-9]|
3[0-689]
)
)\d{6}
@ -6665,9 +6803,14 @@
<exampleNumber>590201234</exampleNumber>
</fixedLine>
<mobile>
<!-- Adding 1[1-9] and 2[013-5] as prefixes after SMSs have been successfully sent to
numbers with this prefix. starpy.net/rates.php also attributes this range to Guadeloupe
Digicel Mobile. -->
<nationalNumberPattern>
690(?:
00|
1[1-9]|
2[013-5]|
[3-5]\d|
6[0-57-9]|
7[1-6]|
@ -7081,8 +7224,78 @@
</territory>
<!-- Guyana -->
<territory id="GY" countryCode="592" internationalPrefix="001"
nationalPrefix="0">
<!-- http://www.itu.int/oth/T020200005D/en -->
<territory id="GY" countryCode="592" internationalPrefix="001">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[2-4679]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>
(?:
2(?:
1[6-9]|
2[0-35-9]|
3[1-4]|
5[3-9]|
6\d|
7[0-24-79]
)|
3(?:
2[25-9]|
3\d
)|
4(?:
4[0-24]|
5[56]
)|
77[1-57]
)\d{4}
</nationalNumberPattern>
<exampleNumber>2201234</exampleNumber>
</fixedLine>
<mobile>
<!-- The ITU document only describes a few ranges for mobile numbers but there is evidence
that SMS messages have been succesfully sent to numbers in the entire range prefixed
with 6. -->
<nationalNumberPattern>6\d{6}</nationalNumberPattern>
<exampleNumber>6091234</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>
(?:
289|
862
)\d{4}
</nationalNumberPattern>
<exampleNumber>2891234</exampleNumber>
</tollFree>
<premiumRate>
<nationalNumberPattern>9008\d{3}</nationalNumberPattern>
<exampleNumber>9008123</exampleNumber>
</premiumRate>
<shortCode>
<nationalNumberPattern>
0(?:
02|
171|
444|
7[67]7|
801|
9(?:
0[78]|
[2-47]
)
)
</nationalNumberPattern>
<possibleNumberPattern>\d{3,4}</possibleNumberPattern>
<exampleNumber>0801</exampleNumber>
</shortCode>
</territory>
<!-- Hong Kong -->
@ -7141,6 +7354,7 @@
<personalNumber>
<nationalNumberPattern>8[1-3]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>81123456</exampleNumber>
</personalNumber>
</territory>
@ -9116,19 +9330,19 @@
876(?:
(?:
5[0-26]|
6\d|
7[1-6]|
9[2-8]
6\d
)\d{5}|
(?:
7(?:
0[2-689]|
[1-6]\d|
8[056]|
9[45]
)|
9(?:
0[1-8]|
1[02378]|
[2-8]\d|
9[2-468]
)
)\d{4}
@ -9137,18 +9351,18 @@
<exampleNumber>8765123456</exampleNumber>
</fixedLine>
<mobile>
<!-- Adding 31 as the prefix was found to be valid by sending SMSs and looking at online
number lookup sites. -->
<!-- Adding 27, 28 and 31 as extra prefixes, as they have been found to be valid by sending
SMSs and looking at online number lookup sites. -->
<nationalNumberPattern>
876(?:
(?:
21|
2[178]|
[348]\d|
5[78]|
77
5[78]
)\d|
7(?:
0[07]|
7\d|
8[1-47-9]|
9[0-36-9]
)|
@ -10341,15 +10555,18 @@
<exampleNumber>23456789</exampleNumber>
</fixedLine>
<mobile>
<!-- Adding 171, 13X, 85[2-689] and 921 prefixes as SMS messages could be successfully
delivered to these mobile numbers. -->
<!-- Adding 171, 13X, 80[89], 85[2-689] and 921 prefixes as SMS messages could be
successfully delivered to these mobile numbers. -->
<nationalNumberPattern>
(?:
(?:
1[0-35-9]|
9[1-49]
)[1-9]|
85[2-689]
8(?:
0[89]|
5[2-689]
)
)\d{5}
</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
@ -11145,7 +11362,7 @@
[89][01]|
7(?:
[01]|
66)
6[67])
</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
@ -11173,7 +11390,7 @@
3\d|
7(?:
[01]\d|
66
6[67]
)
)\d{5}
</nationalNumberPattern>
@ -11181,14 +11398,14 @@
<exampleNumber>71123456</exampleNumber>
</mobile>
<premiumRate>
<nationalNumberPattern>8[01]\d{6}</nationalNumberPattern>
<nationalNumberPattern>9[01]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>80123456</exampleNumber>
<exampleNumber>90123456</exampleNumber>
</premiumRate>
<sharedCost>
<nationalNumberPattern>9[01]\d{6}</nationalNumberPattern>
<nationalNumberPattern>8[01]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>90123456</exampleNumber>
<exampleNumber>80123456</exampleNumber>
</sharedCost>
</territory>
@ -11838,7 +12055,9 @@
<exampleNumber>212345678</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>9[12356]\d{7}</nationalNumberPattern>
<!-- The prefix 094 has been added on the strength of numbers found online, and numbers
where SMS messages have been apparently successfully received. -->
<nationalNumberPattern>9[1-6]\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>912345678</exampleNumber>
</mobile>
@ -13011,9 +13230,10 @@
<exampleNumber>6701234</exampleNumber>
</fixedLine>
<mobile>
<!-- 7[45] has been added as many numbers online have been found with this prefix. -->
<nationalNumberPattern>
(?:
7[36-9]|
7[3-9]|
9[6-9]
)\d{5}
</nationalNumberPattern>
@ -13712,7 +13932,43 @@
</territory>
<!-- Norfolk Island -->
<!-- http://www.itu.int/oth/T020200009D/en -->
<!-- Including numbers for Australian Antarctic stations. -->
<territory id="NF" countryCode="672" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{2})(\d{4})">
<leadingDigits>1</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d)(\d{5})">
<leadingDigits>3</leadingDigits>
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[13]\d{5}</nationalNumberPattern>
<possibleNumberPattern>\d{5,6}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<!-- ITU says all 3X numbers except 38 are fixed-line, but 3[3-79] numbers don't seem to
connect after we tried calling them. -->
<nationalNumberPattern>
(?:
1(?:
06|
17|
28|
39
)|
3[012]\d
)\d{3}
</nationalNumberPattern>
<exampleNumber>106609</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>38\d{4}</nationalNumberPattern>
<exampleNumber>381234</exampleNumber>
</mobile>
</territory>
<!-- Nigeria -->
@ -13818,8 +14074,29 @@
</territory>
<!-- Nicaragua -->
<territory id="NI" countryCode="505" internationalPrefix="00"
nationalPrefix="0">
<!-- http://www.itu.int/oth/T020200009A/en -->
<territory id="NI" countryCode="505" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{4})(\d{4})">
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[128]\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>2\d{7}</nationalNumberPattern>
<exampleNumber>21234567</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>8\d{7}</nationalNumberPattern>
<exampleNumber>81234567</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>1800\d{4}</nationalNumberPattern>
<exampleNumber>18001234</exampleNumber>
</tollFree>
</territory>
<!-- Netherlands -->
@ -14047,8 +14324,41 @@
</territory>
<!-- Nauru -->
<territory id="NR" countryCode="674" internationalPrefix="00"
nationalPrefix="0">
<!-- http://www.itu.int/oth/T0202000094/en -->
<territory id="NR" countryCode="674" internationalPrefix="00">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[458]\d{6}</nationalNumberPattern>
<possibleNumberPattern>\d{7}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>
(?:
444|
888
)\d{4}
</nationalNumberPattern>
<exampleNumber>4441234</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>55[5-9]\d{4}</nationalNumberPattern>
<exampleNumber>5551234</exampleNumber>
</mobile>
<shortCode>
<nationalNumberPattern>
1(?:
1[012]|
23|
92
)
</nationalNumberPattern>
<possibleNumberPattern>\d{3}</possibleNumberPattern>
<exampleNumber>110</exampleNumber>
</shortCode>
</territory>
<!-- Niue -->
@ -14239,7 +14549,7 @@
<!-- Peru -->
<!-- http://www.itu.int/oth/T02020000A6/en -->
<!-- http://en.wikipedia.org/wiki/+51 -->
<territory id="PE" countryCode="51" internationalPrefix="00"
<territory id="PE" countryCode="51" internationalPrefix="19(?:1[124]|77|90)00"
nationalPrefix="0" nationalPrefixFormattingRule="($FG)"
preferredExtnPrefix=" Anexo ">
<availableFormats>
@ -14727,13 +15037,15 @@
<exampleNumber>2123456789</exampleNumber>
</fixedLine>
<mobile>
<!-- Adding 347 as SMSs have been successfully sent to these numbers and numbers can be
found online with these prefixes. -->
<nationalNumberPattern>
3(?:
0\d|
1[2-5]|
2[1-3]|
3[1-6]|
4[2-6]|
4[2-7]|
64
)\d{7}
</nationalNumberPattern>
@ -16620,22 +16932,16 @@
<!-- Swaziland -->
<!-- http://www.itu.int/oth/T02020000C6/en -->
<!-- Note this plan is scheduled to change in February 2011 so should be updated at that time.
-->
<territory id="SZ" countryCode="268" internationalPrefix="00" leadingZeroPossible="true">
<availableFormats>
<numberFormat pattern="(\d{3})(\d{4})">
<leadingDigits>[2-6]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
<numberFormat pattern="(\d{4})(\d{4})">
<leadingDigits>[027]</leadingDigits>
<format>$1 $2</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[02-7]\d{6,7}</nationalNumberPattern>
<possibleNumberPattern>\d{7,8}</possibleNumberPattern>
<nationalNumberPattern>[027]\d{7}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
</generalDesc>
<noInternationalDialling>
<nationalNumberPattern>0800\d{4}</nationalNumberPattern>
@ -16643,10 +16949,8 @@
<exampleNumber>08001234</exampleNumber>
</noInternationalDialling>
<fixedLine>
<!-- The leading optional 2 is because future changes to the fixed-line plan will be made by
prepending a two to fixed-line numbers. -->
<nationalNumberPattern>
2?(?:
2(?:
2(?:
0[07]|
[13]7|
@ -16660,10 +16964,6 @@
)|
(?:
40[4-69]|
16|
2[12]|
3[57]|
[4578]2|
67
)|
5(?:
@ -16675,20 +16975,14 @@
)
)\d{4}
</nationalNumberPattern>
<exampleNumber>2171234</exampleNumber>
<exampleNumber>22171234</exampleNumber>
</fixedLine>
<mobile>
<nationalNumberPattern>
(?:
6|
7[6-8]
)\d{6}
</nationalNumberPattern>
<nationalNumberPattern>7[6-8]\d{6}</nationalNumberPattern>
<exampleNumber>76123456</exampleNumber>
</mobile>
<tollFree>
<nationalNumberPattern>0800\d{4}</nationalNumberPattern>
<possibleNumberPattern>\d{8}</possibleNumberPattern>
<exampleNumber>08001234</exampleNumber>
</tollFree>
</territory>
@ -16931,7 +17225,7 @@
<!-- Tajikistan -->
<!-- http://www.itu.int/oth/T02020000CA/en -->
<territory id="TJ" countryCode="992" internationalPrefix="8~10"
nationalPrefix="8" nationalPrefixFormattingRule="$NP$FG">
nationalPrefix="8" nationalPrefixFormattingRule="($NP) $FG">
<availableFormats>
<numberFormat pattern="([349]\d{2})(\d{2})(\d{4})">
<leadingDigits>
@ -16940,9 +17234,10 @@
</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
<numberFormat pattern="([49]\d)(\d{3})(\d{4})">
<numberFormat pattern="([459]\d)(\d{3})(\d{4})">
<leadingDigits>
4[48]|
5|
9(?:
19|
[0235-9]
@ -16972,7 +17267,7 @@
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[349]\d{8}</nationalNumberPattern>
<nationalNumberPattern>[3-59]\d{8}</nationalNumberPattern>
<possibleNumberPattern>\d{3,9}</possibleNumberPattern>
</generalDesc>
<fixedLine>
@ -16981,7 +17276,7 @@
3(?:
1[3-5]|
2[245]|
31|
3[12]|
4[24-7]|
5[25]|
72
@ -16998,7 +17293,12 @@
<mobile>
<!-- Adding 90 prefix as SMS messages could be successfully delivered to these mobile
numbers. -->
<nationalNumberPattern>9[0-35-9]\d{7}</nationalNumberPattern>
<nationalNumberPattern>
(?:
505|
9[0-35-9]\d
)\d{6}
</nationalNumberPattern>
<possibleNumberPattern>\d{9}</possibleNumberPattern>
<exampleNumber>917123456</exampleNumber>
</mobile>
@ -17307,7 +17607,26 @@
</territory>
<!-- Tuvalu -->
<!-- http://www.itu.int/oth/T02020000D9/en -->
<territory id="TV" countryCode="688" internationalPrefix="00">
<!-- Numbers are formatted as a block. -->
<generalDesc>
<nationalNumberPattern>[29]\d{4,5}</nationalNumberPattern>
<possibleNumberPattern>\d{5,6}</possibleNumberPattern>
</generalDesc>
<fixedLine>
<nationalNumberPattern>2[02-9]\d{3}</nationalNumberPattern>
<possibleNumberPattern>\d{5}</possibleNumberPattern>
<exampleNumber>20123</exampleNumber>
</fixedLine>
<mobile>
<!-- Some numbers online can be found that are 5-digits long, and start with 90 or 91. We
don't know if these are valid or not - the ITU document excludes them - so are not
covering these for now. -->
<nationalNumberPattern>90\d{4}</nationalNumberPattern>
<possibleNumberPattern>\d{6}</possibleNumberPattern>
<exampleNumber>901234</exampleNumber>
</mobile>
</territory>
<!-- Taiwan, China -->
@ -17741,7 +18060,7 @@
0[1-57-9]|
1[0235-8]|
20|
3[014]|
3[0149]|
4[01]|
5[19]|
6[1-37]|
@ -17783,7 +18102,7 @@
9(?:
0[1346-9]|
1[02-9]|
2[058]|
2[0589]|
3[1678]|
4[0179]|
5[1246]|
@ -17833,7 +18152,7 @@
0[1-57-9]|
1[0235-8]|
20|
3[014]|
3[0149]|
4[01]|
5[19]|
6[1-37]|
@ -17875,7 +18194,7 @@
9(?:
0[1346-9]|
1[02-9]|
2[058]|
2[0589]|
3[1678]|
4[0179]|
5[1246]|


+ 6
- 0
resources/PhoneNumberMetaDataForTesting.xml View File

@ -365,6 +365,12 @@
<leadingDigits>[23]</leadingDigits>
<format>$1 $2 $3</format>
</numberFormat>
<!-- The following numberFormat is added to test that the format containing the star sign is
not used by the AYTF. -->
<numberFormat pattern="(\d{4})">
<leadingDigits>[23]</leadingDigits>
<format>*$1</format>
</numberFormat>
</availableFormats>
</territory>


Loading…
Cancel
Save