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

Commit 0f6357d8 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa Committed by Android Git Automerger
Browse files

am 67d9aa15: Merge change I6173d7c7 into eclair-mr2

Merge commit '67d9aa15' into eclair-mr2-plus-aosp

* commit '67d9aa15':
  Add isPrintableAscii() and isPrintableAsciiOnly() to TextUtils.java as hidden methods, and make vCard code use them.
parents 9ee55cc1 67d9aa15
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -359,20 +359,14 @@ public class VCardUtils {
        if (values == null) {
            return true;
        }
        final int asciiFirst = 0x20;
        final int asciiLast = 0x7E;  // included
        for (final String value : values) {
            if (TextUtils.isEmpty(value)) {
                continue;
            }
            final int length = value.length();
            for (int i = 0; i < length; i = value.offsetByCodePoints(i, 1)) {
                final int c = value.codePointAt(i);
                if (!((asciiFirst <= c && c <= asciiLast) || c == '\r' || c == '\n')) {
            if (!TextUtils.isPrintableAsciiOnly(value)) {
                return false;
            }
        }
        }
        return true;
    }

+22 −0
Original line number Diff line number Diff line
@@ -1500,6 +1500,28 @@ public class TextUtils {
        return true;
    }

    /**
     * @hide
     */
    public static boolean isPrintableAscii(final char c) {
        final int asciiFirst = 0x20;
        final int asciiLast = 0x7E;  // included
        return (asciiFirst <= c && c <= asciiLast) || c == '\r' || c == '\n';
    }

    /**
     * @hide
     */
    public static boolean isPrintableAsciiOnly(final CharSequence str) {
        final int len = str.length();
        for (int i = 0; i < len; i++) {
            if (!isPrintableAscii(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    /**
     * Capitalization mode for {@link #getCapsMode}: capitalize all
     * characters.  This value is explicitly defined to be the same as