Added API to replace unicoded digits to ascii numbers

Users can enter arabic phone number or click arabic phone number
to send MMS. Works for generic Unicode digits (full-width, etc.).

bug:5615791
Change-Id: Ieec8c5c6c3736ee2b4ac8ddf17f8c41b2001460e

Signed-off-by: Jake Hamby <jhamby@google.com>
This commit is contained in:
jshin
2012-01-13 10:25:16 -08:00
committed by Jake Hamby
parent e333c82da3
commit f80310d3c5

View File

@@ -1502,6 +1502,27 @@ public class PhoneNumberUtils
return sb.toString();
}
/**
* Replace arabic/unicode digits with decimal digits.
* @param number
* the number to be normalized.
* @return the replaced number.
*
* @hide
*/
public static String replaceUnicodeDigits(String number) {
StringBuilder normalizedDigits = new StringBuilder(number.length());
for (char c : number.toCharArray()) {
int digit = Character.digit(c, 10);
if (digit != -1) {
normalizedDigits.append(digit);
} else {
normalizedDigits.append(c);
}
}
return normalizedDigits.toString();
}
// Three and four digit phone numbers for either special services,
// or 3-6 digit addresses from the network (eg carrier-originated SMS messages) should
// not match.