Browse Source

Update formatForMobileDialling() to return intl format for Uzbek numbers (#2184)

* Update formatForMobileDialling() to return E.164 format instead of national format for Uzbek phone numbers.

* Update java doc to be more clear
pull/2186/head
penmetsaa 8 years ago
committed by GitHub
parent
commit
597983dc4d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 231 additions and 71 deletions
  1. +11
    -4
      cpp/src/phonenumbers/phonenumberutil.cc
  2. +78
    -56
      cpp/src/phonenumbers/test_metadata.cc
  3. +18
    -0
      cpp/test/phonenumbers/phonenumberutil_test.cc
  4. +4
    -0
      cpp/test/phonenumbers/test_util.h
  5. +10
    -5
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  6. +6
    -2
      java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java
  7. +13
    -0
      java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  8. +1
    -0
      java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java
  9. BIN
      java/libphonenumber/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_UZ
  10. +29
    -0
      javascript/i18n/phonenumbers/metadatafortesting.js
  11. +10
    -4
      javascript/i18n/phonenumbers/phonenumberutil.js
  12. +26
    -0
      javascript/i18n/phonenumbers/phonenumberutil_test.js
  13. +1
    -0
      javascript/i18n/phonenumbers/regioncodefortesting.js
  14. +24
    -0
      resources/PhoneNumberMetadataForTesting.xml

+ 11
- 4
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -1226,9 +1226,9 @@ void PhoneNumberUtil::FormatNumberForMobileDialing(
Format(number_no_extension, NATIONAL, formatted_number);
}
} else {
// For non-geographical countries, and Mexican and Chilean fixed line and
// mobile numbers, we output international format for numbers that can be
// dialed internationally as that always works.
// For non-geographical countries, and Mexican, Chilean and Uzbek fixed
// line and mobile numbers, we output international format for numbers
// that can be dialed internationally as that always works.
if ((region_code == kRegionCodeForNonGeoEntity ||
// MX fixed line and mobile numbers should always be formatted in
// international format, even when dialed within MX. For national
@ -1241,8 +1241,15 @@ void PhoneNumberUtil::FormatNumberForMobileDialing(
// national format, but don't have it when used for display. The
// reverse is true for mobile numbers. As a result, we output them in
// the international format to make it work.
// UZ mobile and fixed-line numbers have to be formatted in
// international format or prefixed with special codes like 03, 04
// (for fixed-line) and 05 (for mobile) for dialling successfully
// from mobile devices. As we do not have complete information on
// special codes and to be consistent with formatting across all
// phone types we return the number in international format here.
((region_code == "MX" ||
region_code == "CL") &&
region_code == "CL" ||
region_code == "UZ") &&
is_fixed_line_or_mobile)) &&
CanBeInternationallyDialled(number_no_extension)) {
Format(number_no_extension, INTERNATIONAL, formatted_number);


+ 78
- 56
cpp/src/phonenumbers/test_metadata.cc View File

@ -920,72 +920,94 @@ static const unsigned char data[] = {
0x38, 0x30, 0x30, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0xCA, 0x01, 0x0B,
0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xE2, 0x01,
0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x80,
0x02, 0x01, 0x0A, 0xE1, 0x01, 0x0A, 0x0E, 0x12, 0x0A, 0x5B, 0x32, 0x36, 0x38,
0x5D, 0x5C, 0x64, 0x7B, 0x38, 0x7D, 0x48, 0x09, 0x12, 0x1B, 0x12, 0x0E, 0x32,
0x36, 0x39, 0x36, 0x5B, 0x30, 0x2D, 0x34, 0x5D, 0x5C, 0x64, 0x7B, 0x34, 0x7D,
0x32, 0x09, 0x32, 0x36, 0x39, 0x36, 0x30, 0x31, 0x32, 0x33, 0x34, 0x1A, 0x15,
0x12, 0x08, 0x36, 0x33, 0x39, 0x5C, 0x64, 0x7B, 0x36, 0x7D, 0x32, 0x09, 0x36,
0x33, 0x39, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36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FF, 0xFF, 0xFF,
0x01, 0x3A, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x01, 0x42, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0x01, 0x4A, 0x03, 0x30, 0x30, 0x31, 0x50, 0xD3, 0x07, 0x90, 0x01, 0x01, 0x9A,
0x01, 0x1E, 0x0A, 0x12, 0x28, 0x5C, 0x64, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34,
0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x08, 0x24, 0x31,
0x20, 0x24, 0x32, 0x20, 0x24, 0x33, 0xAA, 0x01, 0x0B, 0x48, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xC2, 0x01, 0x0B, 0x48, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xCA, 0x01, 0x0B, 0x48, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0xE2, 0x01, 0x0B, 0x48,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01
};
} // namespace


+ 18
- 0
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -1175,6 +1175,24 @@ TEST_F(PhoneNumberUtilTest, FormatNumberForMobileDialing) {
test_number, RegionCode::US(), false, &formatted_number);
EXPECT_EQ("+523312345678", formatted_number);
// Test whether Uzbek phone numbers are returned in international format even
// when dialled from same region or other regions.
// Fixed-line number
test_number.set_country_code(998);
test_number.set_national_number(612201234ULL);
phone_util_.FormatNumberForMobileDialing(
test_number, RegionCode::UZ(), false, &formatted_number);
EXPECT_EQ("+998612201234", formatted_number);
// Mobile number
test_number.set_country_code(998);
test_number.set_national_number(950123456ULL);
phone_util_.FormatNumberForMobileDialing(
test_number, RegionCode::UZ(), false, &formatted_number);
EXPECT_EQ("+998950123456", formatted_number);
phone_util_.FormatNumberForMobileDialing(
test_number, RegionCode::US(), false, &formatted_number);
EXPECT_EQ("+998950123456", formatted_number);
// Non-geographical numbers should always be dialed in international format.
test_number.set_country_code(800);
test_number.set_national_number(12345678ULL);


+ 4
- 0
cpp/test/phonenumbers/test_util.h View File

@ -177,6 +177,10 @@ class RegionCode {
return "US";
}
static const char* UZ() {
return "UZ";
}
static const char* YT() {
return "YT";
}


+ 10
- 5
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -1423,9 +1423,9 @@ public class PhoneNumberUtil {
formattedNumber = format(numberNoExt, PhoneNumberFormat.NATIONAL);
}
} else {
// For non-geographical countries, and Mexican and Chilean fixed line and mobile numbers, we
// output international format for numbers that can be dialed internationally as that always
// works.
// For non-geographical countries, and Mexican, Chilean, and Uzbek fixed line and mobile
// numbers, we output international format for numbers that can be dialed internationally as
// that always works.
if ((regionCode.equals(REGION_CODE_FOR_NON_GEO_ENTITY)
// MX fixed line and mobile numbers should always be formatted in international format,
// even when dialed within MX. For national format to work, a carrier code needs to be
@ -1435,8 +1435,13 @@ public class PhoneNumberUtil {
// CL fixed line numbers need the national prefix when dialing in the national format,
// but don't have it when used for display. The reverse is true for mobile numbers. As
// a result, we output them in the international format to make it work.
|| ((regionCode.equals("MX") || regionCode.equals("CL"))
&& isFixedLineOrMobile))
// UZ mobile and fixed-line numbers have to be formatted in international format or
// prefixed with special codes like 03, 04 (for fixed-line) and 05 (for mobile) for
// dialling successfully from mobile devices. As we do not have complete information on
// special codes and to be consistent with formatting across all phone types we return
// the number in international format here.
|| ((regionCode.equals("MX") || regionCode.equals("CL")
|| regionCode.equals("UZ")) && isFixedLineOrMobile))
&& canBeInternationallyDialled(numberNoExt)) {
formattedNumber = format(numberNoExt, PhoneNumberFormat.INTERNATIONAL);
} else {


+ 6
- 2
java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java View File

@ -31,10 +31,10 @@ public class CountryCodeToRegionCodeMapForTesting {
// countries sharing a calling code, such as the NANPA countries, the one
// indicated with "isMainCountryForCode" in the metadata should be first.
static Map<Integer, List<String>> getCountryCodeToRegionCodeMap() {
// The capacity is set to 36 as there are 27 different entries,
// The capacity is set to 37 as there are 28 different entries,
// and this offers a load factor of roughly 0.75.
Map<Integer, List<String>> countryCodeToRegionCodeMap =
new HashMap<Integer, List<String>>(36);
new HashMap<Integer, List<String>>(37);
ArrayList<String> listWithRegionCode;
@ -153,6 +153,10 @@ public class CountryCodeToRegionCodeMapForTesting {
listWithRegionCode.add("001");
countryCodeToRegionCodeMap.put(979, listWithRegionCode);
listWithRegionCode = new ArrayList<String>(1);
listWithRegionCode.add("UZ");
countryCodeToRegionCodeMap.put(998, listWithRegionCode);
return countryCodeToRegionCodeMap;
}
}

+ 13
- 0
java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java View File

@ -103,6 +103,10 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
private static final PhoneNumber US_SPOOF_WITH_RAW_INPUT =
new PhoneNumber().setCountryCode(1).setNationalNumber(0L)
.setRawInput("000-000-0000");
private static final PhoneNumber UZ_FIXED_LINE =
new PhoneNumber().setCountryCode(998).setNationalNumber(612201234L);
private static final PhoneNumber UZ_MOBILE =
new PhoneNumber().setCountryCode(998).setNationalNumber(950123456L);
private static final PhoneNumber INTERNATIONAL_TOLL_FREE =
new PhoneNumber().setCountryCode(800).setNationalNumber(12345678L);
// We set this to be the same length as numbers for the other non-geographical country prefix that
@ -852,6 +856,15 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase {
assertEquals("+523312345678",
phoneUtil.formatNumberForMobileDialing(MX_NUMBER1, RegionCode.US, false));
// Test whether Uzbek phone numbers are returned in international format even when dialled from
// same region or other regions.
assertEquals("+998612201234",
phoneUtil.formatNumberForMobileDialing(UZ_FIXED_LINE, RegionCode.UZ, false));
assertEquals("+998950123456",
phoneUtil.formatNumberForMobileDialing(UZ_MOBILE, RegionCode.UZ, false));
assertEquals("+998950123456",
phoneUtil.formatNumberForMobileDialing(UZ_MOBILE, RegionCode.US, false));
// Non-geographical numbers should always be dialed in international format.
assertEquals("+80012345678",
phoneUtil.formatNumberForMobileDialing(INTERNATIONAL_TOLL_FREE, RegionCode.US, false));


+ 1
- 0
java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java View File

@ -54,6 +54,7 @@ final class RegionCode {
static final String SE = "SE";
static final String SG = "SG";
static final String US = "US";
static final String UZ = "UZ";
static final String YT = "YT";
static final String ZW = "ZW";
// Official code for the unknown region.


BIN
java/libphonenumber/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_UZ View File


+ 29
- 0
javascript/i18n/phonenumbers/metadatafortesting.js View File

@ -58,6 +58,7 @@ i18n.phonenumbers.metadata.countryCodeToRegionCodeMap = {
,882:["001"]
,971:["AE"]
,979:["001"]
,998:["UZ"]
};
/**
@ -963,6 +964,34 @@ i18n.phonenumbers.metadata.countryToMetadata = {
,,,[,,,,,,,,,[-1]
]
]
,"UZ":[,[,,"[69]\\d{8}",,,,,,,[9]
,[7]
]
,[,,"6122\\d{5}",,,,"662345678",,,,[7]
]
,[,,"9[0-57-9]\\d{7}",,,,"912345678"]
,[,,,,,,,,,[-1]
]
,[,,,,,,,,,[-1]
]
,[,,,,,,,,,[-1]
]
,[,,,,,,,,,[-1]
]
,[,,,,,,,,,[-1]
]
,"UZ",998,"810","8",,,"8",,"8~10",,[[,"([679]\\d)(\\d{3})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[679]"]
,"8 $1"]
]
,,[,,,,,,,,,[-1]
]
,,,[,,,,,,,,,[-1]
]
,[,,,,,,,,,[-1]
]
,,,[,,,,,,,,,[-1]
]
]
,"YT":[,[,,"[268]\\d{8}",,,,,,,[9]
]
,[,,"2696[0-4]\\d{4}",,,,"269601234"]


+ 10
- 4
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -1959,9 +1959,9 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.formatNumberForMobileDialing =
numberNoExt, i18n.phonenumbers.PhoneNumberFormat.NATIONAL);
}
} else {
// For non-geographical countries, Mexican and Chilean fixed line and
// mobile numbers, we output international format for numbers that can be
// dialed internationally, as that always works.
// For non-geographical countries, and Mexican, Chilean and Uzbek fixed
// line and mobile numbers, we output international format for numbers
// that can be dialed internationally as that always works.
if ((regionCode ==
i18n.phonenumbers.PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY ||
// MX fixed line and mobile numbers should always be formatted in
@ -1975,7 +1975,13 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.formatNumberForMobileDialing =
// national format, but don't have it when used for display. The
// reverse is true for mobile numbers. As a result, we output them in
// the international format to make it work.
((regionCode == 'MX' || regionCode == 'CL') &&
// UZ mobile and fixed-line numbers have to be formatted in
// international format or prefixed with special codes like 03, 04
// (for fixed-line) and 05 (for mobile) for dialling successfully
// from mobile devices. As we do not have complete information on
// special codes and to be consistent with formatting across all
// phone types we return the number in international format here.
((regionCode == 'MX' || regionCode == 'CL' || regionCode == 'UZ') &&
isFixedLineOrMobile)) &&
this.canBeInternationallyDialled(numberNoExt)) {
formattedNumber = this.format(


+ 26
- 0
javascript/i18n/phonenumbers/phonenumberutil_test.js View File

@ -218,6 +218,18 @@ US_SPOOF_WITH_RAW_INPUT.setNationalNumber(0);
US_SPOOF_WITH_RAW_INPUT.setRawInput('000-000-0000');
/** @type {i18n.phonenumbers.PhoneNumber} */
var UZ_FIXED_LINE = new i18n.phonenumbers.PhoneNumber();
UZ_FIXED_LINE.setCountryCode(998);
UZ_FIXED_LINE.setNationalNumber(612201234);
/** @type {i18n.phonenumbers.PhoneNumber} */
var UZ_MOBILE = new i18n.phonenumbers.PhoneNumber();
UZ_MOBILE.setCountryCode(998);
UZ_MOBILE.setNationalNumber(950123456);
/** @type {i18n.phonenumbers.PhoneNumber} */
var INTERNATIONAL_TOLL_FREE = new i18n.phonenumbers.PhoneNumber();
INTERNATIONAL_TOLL_FREE.setCountryCode(800);
@ -1150,6 +1162,20 @@ function testFormatNumberForMobileDialing() {
phoneUtil.formatNumberForMobileDialing(MX_NUMBER1, RegionCode.US,
false));
// Test whether Uzbek phone numbers are returned in international format even
// when dialled from same region or other regions.
// Fixed-line number
assertEquals('+998612201234',
phoneUtil.formatNumberForMobileDialing(UZ_FIXED_LINE, RegionCode.UZ,
false));
// Mobile number
assertEquals('+998950123456',
phoneUtil.formatNumberForMobileDialing(UZ_MOBILE, RegionCode.UZ,
false));
assertEquals('+998950123456',
phoneUtil.formatNumberForMobileDialing(UZ_MOBILE, RegionCode.US,
false));
// Non-geographical numbers should always be dialed in international format.
assertEquals('+80012345678',
phoneUtil.formatNumberForMobileDialing(INTERNATIONAL_TOLL_FREE,


+ 1
- 0
javascript/i18n/phonenumbers/regioncodefortesting.js View File

@ -62,6 +62,7 @@ i18n.phonenumbers.RegionCode = {
SE: 'SE',
SG: 'SG',
US: 'US',
UZ: 'UZ',
YT: 'YT',
ZW: 'ZW',
// Official code for the unknown region.


+ 24
- 0
resources/PhoneNumberMetadataForTesting.xml View File

@ -1090,6 +1090,30 @@
</premiumRate>
</territory>
<!-- Uzbekistan -->
<territory id="UZ" countryCode="998" preferredInternationalPrefix="8~10"
internationalPrefix="810" nationalPrefix="8" nationalPrefixFormattingRule="$NP $FG">
<availableFormats>
<numberFormat pattern="([679]\d)(\d{3})(\d{2})(\d{2})">
<leadingDigits>[679]</leadingDigits>
<format>$1 $2 $3 $4</format>
</numberFormat>
</availableFormats>
<generalDesc>
<nationalNumberPattern>[69]\d{8}</nationalNumberPattern>
</generalDesc>
<fixedLine>
<possibleLengths national="9" localOnly="7"/>
<exampleNumber>662345678</exampleNumber>
<nationalNumberPattern>6122\d{5}</nationalNumberPattern>
</fixedLine>
<mobile>
<possibleLengths national="9"/>
<exampleNumber>912345678</exampleNumber>
<nationalNumberPattern>9[0-57-9]\d{7}</nationalNumberPattern>
</mobile>
</territory>
<!-- Mayotte -->
<territory id="YT" countryCode="262" leadingDigits="269|639"
internationalPrefix="00" nationalPrefix="0" nationalPrefixFormattingRule="$NP$FG">


Loading…
Cancel
Save