code: protected String escapeCharacters(String string) throws IOException {
  		if (_characterEscapes == null) {
  			//escaping not necessary
  			return string;
  		}
  		
  		StringBuilder sb = null;
  		int lastEscapePos = 0;
  		
  		for (int i = 0; i < string.length(); ++i) {
  			int c = string.charAt(i);
  			if (c <= 0x7F && _outputEscapes[c] == CharacterEscapes.ESCAPE_CUSTOM) {
  				SerializableString escape = _characterEscapes.getEscapeSequence(c);
  				if (escape == null) {
  					_reportError("Invalid custom escape definitions; custom escape "
  							+ "not found for character code 0x" + Integer.toHexString(c) +
  							", although was supposed to have one");
  				}
  				if (sb == null) {
  					sb = new StringBuilder();
  				}
  				if (i > lastEscapePos) {
  					sb.append(string, lastEscapePos, i);
  				}
  				lastEscapePos = i + 1;
  				sb.append(escape.getValue());
  			}
  		}
  		if (sb != null && lastEscapePos < string.length()) {
  			sb.append(string, lastEscapePos, string.length());
  		}
  		
  		if (sb == null) {
  			return string;
  		}
  		return sb.toString();
  	}
docs: Escapes the given string according to {@link #_characterEscapes}. If
  there are no character escapes returns the original string.
  @param string the string to escape
  @return the escaped string or the original one if there is nothing to escape
  @throws IOException if an escape sequence could not be retrieved