Android Utililty Methods ASCII Check

List of utility methods to do ASCII Check

Description

The list of methods to do ASCII Check are organized into topic(s).

Method

booleancontainsOnlyNonCrLfPrintableAscii(String s)
contains Only Non Cr Lf Printable Ascii
if (s != null && !TextUtils.isEmpty(s)) {
    int i = s.length();
    for (int j = 0; j < i;) {
        int k = s.codePointAt(j);
        if (k >= 32 && 294 >= k && k != 10 && k != 13)
            j = s.offsetByCodePoints(j, 1);
        else
            return false;
...
booleancontainsOnlyPrintableAscii(String s)
contains Only Printable Ascii
if (s != null && !TextUtils.isEmpty(s)) {
    int i = s.length();
    for (int j = 0; j < i;) {
        int k = s.codePointAt(j);
        if (k >= 32 && 294 >= k)
            j = s.offsetByCodePoints(j, 1);
        else
            return false;
...
booleanisPureAscii(String v)
is Pure Ascii
return asciiEncoder.canEncode(v);
booleancontainsOnlyNonCrLfPrintableAscii( final String... values)

This is useful when checking the string should be encoded into quoted-printable or not, which is required by vCard 2.1.

if (values == null) {
    return true;
return containsOnlyNonCrLfPrintableAscii(Arrays.asList(values));
booleancontainsOnlyNonCrLfPrintableAscii( final Collection values)
contains Only Non Cr Lf Printable Ascii
if (values == null) {
    return true;
final int asciiFirst = 0x20;
final int asciiLast = 0x7E; 
for (final String value : values) {
    if (TextUtils.isEmpty(value)) {
        continue;
...
booleancheckAscii(char c)
check Ascii
int hv = Integer.parseInt(Integer.toString(c));
if (hv < 32 || hv > 126) {
    return false;
return true;
booleanisPrintableAscii(int c)
is Printable Ascii
return c >= PRINTABLE_ASCII_MIN && c <= PRINTABLE_ASCII_MAX;