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

Commit 830f24f4 authored by Daisuke Miyakawa's avatar Daisuke Miyakawa Committed by Android Git Automerger
Browse files

am 0f6357d8: am 67d9aa15: Merge change I6173d7c7 into eclair-mr2

Merge commit '0f6357d8'

* commit '0f6357d8':
  Add isPrintableAscii() and isPrintableAsciiOnly() to TextUtils.java as hidden methods, and make vCard code use them.
parents a3e509c2 0f6357d8
Loading
Loading
Loading
Loading
+2 −8
Original line number Original line Diff line number Diff line
@@ -359,20 +359,14 @@ public class VCardUtils {
        if (values == null) {
        if (values == null) {
            return true;
            return true;
        }
        }
        final int asciiFirst = 0x20;
        final int asciiLast = 0x7E;  // included
        for (final String value : values) {
        for (final String value : values) {
            if (TextUtils.isEmpty(value)) {
            if (TextUtils.isEmpty(value)) {
                continue;
                continue;
            }
            }
            final int length = value.length();
            if (!TextUtils.isPrintableAsciiOnly(value)) {
            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')) {
                return false;
                return false;
            }
            }
        }
        }
        }
        return true;
        return true;
    }
    }


+22 −0
Original line number Original line Diff line number Diff line
@@ -1500,6 +1500,28 @@ public class TextUtils {
        return true;
        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
     * Capitalization mode for {@link #getCapsMode}: capitalize all
     * characters.  This value is explicitly defined to be the same as
     * characters.  This value is explicitly defined to be the same as