Browse Source

Merge pull request #1312 from tiagosh/hash_as_diallable_char

Add hash as a diallable char.
pull/1139/merge
lararennie 9 years ago
committed by GitHub
parent
commit
c0d8d4838e
6 changed files with 11 additions and 5 deletions
  1. +1
    -0
      cpp/src/phonenumbers/phonenumberutil.cc
  2. +2
    -2
      cpp/test/phonenumbers/phonenumberutil_test.cc
  3. +1
    -0
      java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java
  4. +2
    -2
      java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java
  5. +3
    -0
      java/pending_code_changes.txt
  6. +2
    -1
      javascript/i18n/phonenumbers/phonenumberutil.js

+ 1
- 0
cpp/src/phonenumbers/phonenumberutil.cc View File

@ -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(


+ 2
- 2
cpp/test/phonenumbers/phonenumberutil_test.cc View File

@ -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";
}


+ 1
- 0
java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java View File

@ -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<Character, Character> allPlusNumberGroupings = new HashMap<Character, Character>();


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

@ -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));


+ 3
- 0
java/pending_code_changes.txt View File

@ -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.

+ 2
- 1
javascript/i18n/phonenumbers/phonenumberutil.js View File

@ -314,7 +314,8 @@ i18n.phonenumbers.PhoneNumberUtil.DIALLABLE_CHAR_MAPPINGS_ = {
'8': '8',
'9': '9',
'+': i18n.phonenumbers.PhoneNumberUtil.PLUS_SIGN,
'*': '*'
'*': '*',
'#': '#'
};


Loading…
Cancel
Save