Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1c23ed62 authored by Jake Hamby's avatar Jake Hamby Committed by Android (Google) Code Review
Browse files

Merge "Added API to replace unicoded digits to ascii numbers"

parents d207e2de f80310d3
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -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.