diff options
author | Dmitri Plotnikov <dplotnikov@google.com> | 2011-01-06 13:48:50 -0800 |
---|---|---|
committer | Dmitri Plotnikov <dplotnikov@google.com> | 2011-01-06 13:49:18 -0800 |
commit | 46bdb5c49f8374539ec89e85cbb1a9ee7b3a2b10 (patch) | |
tree | 9967bac9881d54cf6d5690dd1a7be2b002c7e225 /android/PhoneNumberUtils.cpp | |
parent | 95c34edce550d0869113085e0cd1b6b09e8fe38b (diff) |
DO NOT MERGE. Adding a custom function to support legacy API compatibility
Bug: 3210604
Change-Id: Ie65c053ec5178d6cd991f69a5a2b6d5d51938ade
Diffstat (limited to 'android/PhoneNumberUtils.cpp')
-rw-r--r-- | android/PhoneNumberUtils.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/android/PhoneNumberUtils.cpp b/android/PhoneNumberUtils.cpp index 775e33f..a753f42 100644 --- a/android/PhoneNumberUtils.cpp +++ b/android/PhoneNumberUtils.cpp @@ -433,4 +433,40 @@ bool phone_number_compare_strict(const char* a, const char* b) return phone_number_compare_inter(a, b, true); } +/** + * Imitates the Java method PhoneNumberUtils.getStrippedReversed. + * Used for API compatibility with Android 1.6 and earlier. + */ +bool phone_number_stripped_reversed_inter(const char* in, char* out, const int len, int *outlen) { + int in_len = strlen(in); + int out_len = 0; + bool have_seen_plus = false; + for (int i = in_len; --i >= 0;) { + char c = in[i]; + if ((c >= '0' && c <= '9') || c == '*' || c == '#' || c == 'N') { + if (out_len < len) { + out[out_len++] = c; + } + } else { + switch (c) { + case '+': + if (!have_seen_plus) { + if (out_len < len) { + out[out_len++] = c; + } + have_seen_plus = true; + } + break; + case ',': + case ';': + out_len = 0; + break; + } + } + } + + *outlen = out_len; + return true; +} + } // namespace android |