Counts spaces in the string.

@param str The string.
@return The number of spaces.
558674
private static int countSpaces(String str) {
    int counter = 0;
    for (char c : str.toCharArray()) {
      if (c == ' ') {
        counter++;
      }
    }
    return counter;
  }
939352
function handleSpaces(str, i, out) { //return int
	var found = 0;
	var orig_i = i;
	while (i < str.length && str.charAt(i) == ' ') {
		i++;
		found++;
	}
	if (found == 0 || i == str.length) return 0;
	var t = str.charAt(i);
	if (tib_top(t) == null && tib_other(t) == null) return 0;
	// found 'found' spaces between two tibetan bits; generate the same number of '_'s
	for (i = 0; i < found; i++) out += '_';
	return found;
}
617639
private String generateSpaces(int count) {
        String spaces = "";
        for (int i = 0; i < count; i++) {
            spaces += " ";
        }
        return spaces;
    }
34534
public static int skipSpaces(String s, int start) {

        int limit = s.length();
        int i     = start;

        for (; i < limit; i++) {
            if (s.charAt(i) != ' ') {
                break;
            }
        }

        return i;
    }
1321044
public static boolean containsWhitespace(final String str) {
        if (N.isNullOrEmpty(str)) {
            return false;
        }

        final char[] chars = getCharsForReadOnly(str);
        for (int i = 0, len = str.length(); i < len; i++) {
            if (Character.isWhitespace(chars[i])) {
                return true;
            }
        }

        return false;
    }
1140949
String cleanOutputWhitespace(String str) {
		StringBuilder sb = new StringBuilder(str.length());

		int currentWhitespaceStart = -1;
		int startOfLine = 0;

		for (int i = 0; i < str.length(); i++) {
			char c = str.charAt(i);

			boolean isInlineWhitespace = c == ' ' || c == '\t';

			if (isInlineWhitespace && currentWhitespaceStart == -1)
				currentWhitespaceStart = i;

			if (!isInlineWhitespace) {
				if (c != '\n' && currentWhitespaceStart > 0 && currentWhitespaceStart != startOfLine) {
					sb.append(' ');
				}
				currentWhitespaceStart = -1;
			}

			if (c == '\n')
				startOfLine = i + 1;

			if (!isInlineWhitespace)
				sb.append(c);
		}

		return sb.toString();
	}
902719
public static boolean isEmpty(String str) {
        if (str == null)
            return true;
        if ("".equals(str.trim()))
            return true;
        return str.isEmpty();
    }
570228
private static int countSpacesLeft(char[] dest,
                                       int start,
                                       int count) {
        for (int i = start, e = start + count; i < e; ++i) {
            if (dest[i] != SPACE_CHAR) {
                return i - start;
            }
        }
        return count;
    }
1209791
protected int _countPeriods(String str)
    {
        int commas = 0;
        for (int i = 0, end = str.length(); i < end; ++i) {
            int ch = str.charAt(i);
            if (ch < '0' || ch > '9') {
                if (ch == '.') {
                    ++commas;
                } else {
                    return -1;
                }
            }
        }
        return commas;
    }
1277700
public static boolean isEmpty(@Nullable String str) {
        if (str == null || str.length() == 0) {
            return true;
        }
        return false;
    }
1258405
public void addString(String str) {
        if (mSize == mStrings.length) {
            String[] old = mStrings;
            int oldSize = old.length;
            mStrings = new String[oldSize + (oldSize << 1)];
            System.arraycopy(old, 0, mStrings, 0, oldSize);
        }
        mStrings[mSize++] = str;
    }
141185
public void add(String str) {
	curr.next = new Entry(str, Entry.NUL);
	curr = curr.next;
	count++;
    }
604565
public static boolean isWhiteSpace(String s)
  {

    if(null != s)
    {
      int n = s.length();
  
      for (int i = 0; i < n; i++)
      {
        if (!isWhiteSpace(s.charAt(i)))
          return false;
      }
    }

    return true;
  }
462982
public static String trimWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        while (buf.length() > 0 && Character.isWhitespace(buf.charAt(0))) {
            buf.deleteCharAt(0);
        }
        while (buf.length() > 0 && Character.isWhitespace(buf.charAt(buf.length() - 1))) {
            buf.deleteCharAt(buf.length() - 1);
        }
        return buf.toString();
    }
1008817
public static String trimAllWhitespace(String str) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder sb = new StringBuilder(str);
        int index = 0;
        while (sb.length() > index) {
            if (Character.isWhitespace(sb.charAt(index))) {
                sb.deleteCharAt(index);
            }
            else {
                index++;
            }
        }
        return sb.toString();
    }
21222
def count_indents_length(self, spacecount, tabs=0, offset=0):
        
        if not self.has_space(offset=offset):
            return 0
        spaces = 0
        indents = 0
        charlen = 0
        for char in self.string[self.pos + offset - self.col:]:
            if char == ' ':
                spaces += 1
            elif tabs and char == '\t':
                indents += 1
                spaces = 0
            else:
                break
            charlen += 1
            if spaces == spacecount:
                indents += 1
                spaces = 0
        return (indents, charlen)
575530
public static int countPuncs(String str) {
		int count = 0;
	    
		for (int i = 0; i < str.length(); i++) {
		    if (str.charAt(i) == '.' || str.charAt(i) == '?' || str.charAt(i) == '!' ||
				str.charAt(i) == ',' || str.charAt(i) == ':' || str.charAt(i) == ';') {
			count++;
		    }
		}
		
		return count;
    }