|| (ch >= '0' && ch <= '9')
|| legal.indexOf(ch) > -1
|| (ch > 127 && !isSpaceChar(ch) && !TCharacter.isISOControl(ch))) {
buf.append(ch);
} else {
byte[] bytes = new TString(new char[] { ch }).getBytes();
for (int j = 0; j < bytes.length; j++) {
buf.append('%');
buf.append(digits.charAt((bytes[j] & 0xf0) >> 4));
buf.append(digits.charAt(bytes[j] & 0xf));
}