diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index 29a1609fa..f0b4e5a29 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -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); diff --git a/cpp/src/phonenumbers/test_metadata.cc b/cpp/src/phonenumbers/test_metadata.cc index 4ed3b2ffb..f0da1d81f 100644 --- a/cpp/src/phonenumbers/test_metadata.cc +++ b/cpp/src/phonenumbers/test_metadata.cc @@ -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, 0x22, 0x14, 0x12, 0x07, 0x38, - 0x30, 0x5C, 0x64, 0x7B, 0x37, 0x7D, 0x32, 0x09, 0x38, 0x30, 0x31, 0x32, 0x33, - 0x34, 0x35, 0x36, 0x37, 0x2A, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0x01, 0x32, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 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, 0x02, 0x59, 0x54, 0x50, 0x86, 0x02, 0x5A, 0x02, - 0x30, 0x30, 0x62, 0x01, 0x30, 0x7A, 0x01, 0x30, 0xAA, 0x01, 0x0B, 0x48, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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x0E, 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, - 0x28, 0x5C, 0x64, 0x7B, 0x34, 0x7D, 0x29, 0x12, 0x05, 0x24, 0x31, 0x20, 0x24, - 0x32, 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, 0x0A, 0xCE, 0x01, 0x0A, 0x09, 0x12, 0x05, 0x5C, - 0x64, 0x7B, 0x39, 0x7D, 0x48, 0x09, 0x12, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x1A, 0x12, 0x12, 0x05, 0x5C, 0x64, 0x7B, - 0x39, 0x7D, 0x32, 0x09, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x22, 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, + 0x02, 0x01, 0x0A, 0x97, 0x02, 0x0A, 0x0F, 0x12, 0x09, 0x5B, 0x36, 0x39, 0x5D, + 0x5C, 0x64, 0x7B, 0x38, 0x7D, 0x48, 0x09, 0x50, 0x07, 0x12, 0x18, 0x12, 0x09, + 0x36, 0x31, 0x32, 0x32, 0x5C, 0x64, 0x7B, 0x35, 0x7D, 0x32, 0x09, 0x36, 0x36, + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x50, 0x07, 0x1A, 0x1B, 0x12, 0x0E, + 0x39, 0x5B, 0x30, 0x2D, 0x35, 0x37, 0x2D, 0x39, 0x5D, 0x5C, 0x64, 0x7B, 0x37, + 0x7D, 0x32, 0x09, 0x39, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x22, + 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x2A, + 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x32, + 0x0B, 0x48, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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, + 0x02, 0x55, 0x5A, 0x50, 0xE6, 0x07, 0x5A, 0x03, 0x38, 0x31, 0x30, 0x62, 0x01, + 0x38, 0x7A, 0x01, 0x38, 0x8A, 0x01, 0x04, 0x38, 0x7E, 0x31, 0x30, 0x9A, 0x01, + 0x3A, 0x0A, 0x1E, 0x28, 0x5B, 0x36, 0x37, 0x39, 0x5D, 0x5C, 0x64, 0x29, 0x28, + 0x5C, 0x64, 0x7B, 0x33, 0x7D, 0x29, 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, + 0x28, 0x5C, 0x64, 0x7B, 0x32, 0x7D, 0x29, 0x12, 0x0B, 0x24, 0x31, 0x20, 0x24, + 0x32, 0x20, 0x24, 0x33, 0x20, 0x24, 0x34, 0x1A, 0x05, 0x5B, 0x36, 0x37, 0x39, + 0x5D, 0x22, 0x04, 0x38, 0x20, 0x24, 0x31, 0xAA, 0x01,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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 diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 4eb7a3ac4..26710031d 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -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); diff --git a/cpp/test/phonenumbers/test_util.h b/cpp/test/phonenumbers/test_util.h index a15531343..36d761867 100644 --- a/cpp/test/phonenumbers/test_util.h +++ b/cpp/test/phonenumbers/test_util.h @@ -177,6 +177,10 @@ class RegionCode { return "US"; } + static const char* UZ() { + return "UZ"; + } + static const char* YT() { return "YT"; } diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 87eadc374..02b5b937e 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -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 { diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java index 9fd087756..067f4d24d 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/CountryCodeToRegionCodeMapForTesting.java @@ -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> 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> countryCodeToRegionCodeMap = - new HashMap>(36); + new HashMap>(37); ArrayList listWithRegionCode; @@ -153,6 +153,10 @@ public class CountryCodeToRegionCodeMapForTesting { listWithRegionCode.add("001"); countryCodeToRegionCodeMap.put(979, listWithRegionCode); + listWithRegionCode = new ArrayList(1); + listWithRegionCode.add("UZ"); + countryCodeToRegionCodeMap.put(998, listWithRegionCode); + return countryCodeToRegionCodeMap; } } diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 5da7e9c95..73b46c7fd 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -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)); diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java index a5939fe9e..d24c836f7 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/RegionCode.java @@ -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. diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_UZ b/java/libphonenumber/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_UZ new file mode 100644 index 000000000..ae246439a Binary files /dev/null and b/java/libphonenumber/test/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProtoForTesting_UZ differ diff --git a/javascript/i18n/phonenumbers/metadatafortesting.js b/javascript/i18n/phonenumbers/metadatafortesting.js index dcbe27c36..1445ea27f 100644 --- a/javascript/i18n/phonenumbers/metadatafortesting.js +++ b/javascript/i18n/phonenumbers/metadatafortesting.js @@ -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"] diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 2445ec325..ab4b28dae 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -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( diff --git a/javascript/i18n/phonenumbers/phonenumberutil_test.js b/javascript/i18n/phonenumbers/phonenumberutil_test.js index a2e605f63..7dfdaba90 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil_test.js +++ b/javascript/i18n/phonenumbers/phonenumberutil_test.js @@ -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, diff --git a/javascript/i18n/phonenumbers/regioncodefortesting.js b/javascript/i18n/phonenumbers/regioncodefortesting.js index d465bf1ff..99324ccc8 100644 --- a/javascript/i18n/phonenumbers/regioncodefortesting.js +++ b/javascript/i18n/phonenumbers/regioncodefortesting.js @@ -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. diff --git a/resources/PhoneNumberMetadataForTesting.xml b/resources/PhoneNumberMetadataForTesting.xml index 936fefa0f..3e773e7c6 100644 --- a/resources/PhoneNumberMetadataForTesting.xml +++ b/resources/PhoneNumberMetadataForTesting.xml @@ -1090,6 +1090,30 @@ + + + + + [679] + $1 $2 $3 $4 + + + + [69]\d{8} + + + + 662345678 + 6122\d{5} + + + + 912345678 + 9[0-57-9]\d{7} + + +