diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index 31163acf5..7704fe990 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -314,6 +314,7 @@ class PhoneNumberRegExpsAndMappings { void InitializeMapsAndSets() { diallable_char_mappings_.insert(std::make_pair('+', '+')); diallable_char_mappings_.insert(std::make_pair('*', '*')); + diallable_char_mappings_.insert(std::make_pair('#', '#')); // Here we insert all punctuation symbols that we wish to respect when // formatting alpha numbers, as they show the intended number groupings. all_plus_number_grouping_symbols_.insert( diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 00b8f625f..8caee8a95 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -2504,9 +2504,9 @@ TEST_F(PhoneNumberUtilTest, NormaliseStripAlphaCharacters) { } TEST_F(PhoneNumberUtilTest, NormaliseStripNonDiallableCharacters) { - string input_number("03*4-56&+a#234"); + string input_number("03*4-56&+1a#234"); NormalizeDiallableCharsOnly(&input_number); - static const string kExpectedOutput("03*456+234"); + static const string kExpectedOutput("03*456+1#234"); EXPECT_EQ(kExpectedOutput, input_number) << "Conversion did not correctly remove non-diallable characters"; } diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index ddb26f7cb..af1b803ac 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -197,6 +197,7 @@ public class PhoneNumberUtil { diallableCharMap.putAll(asciiDigitMappings); diallableCharMap.put(PLUS_SIGN, PLUS_SIGN); diallableCharMap.put('*', '*'); + diallableCharMap.put('#', '#'); DIALLABLE_CHAR_MAPPINGS = Collections.unmodifiableMap(diallableCharMap); HashMap allPlusNumberGroupings = new HashMap(); diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index ce3c28c1a..76245ce73 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -426,8 +426,8 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { } public void testNormaliseStripNonDiallableCharacters() { - String inputNumber = "03*4-56&+a#234"; - String expectedOutput = "03*456+234"; + String inputNumber = "03*4-56&+1a#234"; + String expectedOutput = "03*456+1#234"; assertEquals("Conversion did not correctly remove non-diallable characters", expectedOutput, PhoneNumberUtil.normalizeDiallableCharsOnly(inputNumber)); diff --git a/java/pending_code_changes.txt b/java/pending_code_changes.txt index c7fc0af6f..3943d419c 100644 --- a/java/pending_code_changes.txt +++ b/java/pending_code_changes.txt @@ -6,3 +6,6 @@ Code changes: length or not. This could result in more specific results; whereas before, a number from length 3 to length 6 may have been deemed possible, now we may exclude a number of length 5. + - Add hash (#) as a diallable character. Numbers with # in them will no longer + have formatting applied in formatInOriginalFormat, and + normalizeDiallableCharsOnly now retains the # symbol. diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index 5ca14d1b4..b42989915 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -314,7 +314,8 @@ i18n.phonenumbers.PhoneNumberUtil.DIALLABLE_CHAR_MAPPINGS_ = { '8': '8', '9': '9', '+': i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN, - '*': '*' + '*': '*', + '#': '#' };