Keep the '+' when normalizing the phone number

Change-Id: I24731735ed18dbc92a643a0d99d35a1b58be40c8
This commit is contained in:
Dmitri Plotnikov
2010-08-13 11:09:29 -07:00
parent aba188523c
commit 3e4b7c332f
2 changed files with 4 additions and 3 deletions

View File

@@ -1385,7 +1385,7 @@ public class PhoneNumberUtils
* Normalize a phone number by removing the characters other than digits. If
* the given number has keypad letters, the letters will be converted to
* digits first.
*
*
* @param phoneNumber
* the number to be normalized.
* @return the normalized number.
@@ -1397,9 +1397,9 @@ public class PhoneNumberUtils
int len = phoneNumber.length();
for (int i = 0; i < len; i++) {
char c = phoneNumber.charAt(i);
if (PhoneNumberUtils.isISODigit(c)) {
if ((i == 0 && c == '+') || PhoneNumberUtils.isISODigit(c)) {
sb.append(c);
} else if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') {
} else if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
return normalizeNumber(PhoneNumberUtils.convertKeypadLettersToDigits(phoneNumber));
}
}

View File

@@ -524,6 +524,7 @@ public class PhoneNumberUtilsTest extends AndroidTestCase {
assertEquals("6502910000", PhoneNumberUtils.normalizeNumber("650 2910000"));
assertEquals("1234567", PhoneNumberUtils.normalizeNumber("12,3#4*567"));
assertEquals("8004664114", PhoneNumberUtils.normalizeNumber("800-GOOG-114"));
assertEquals("+16502910000", PhoneNumberUtils.normalizeNumber("+1 650 2910000"));
}
}