code: 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;
  }
docs: handles spaces (if any) in the input stream, turning them into '_'. this is abstracted out because in non-escaping mode, we only want to turn spaces into _ when they come in the middle of Tibetan script.