write the encoded version of a given string
if (xmlString == null) {
return;
}
int length = xmlString.length();
char character;
for (int i = 0; i < length; i++) {
character = xmlString.charAt( i );
switch (character) {
// we don't care about single quotes since axis will
// use double quotes anyway
case '&":
writer.write(AMP);
break;
case '"":
writer.write(QUOTE);
break;
case '<":
writer.write(LESS);
break;
case '>":
writer.write(GREATER);
break;
case '\n":
writer.write(LF);
break;
case '\r":
writer.write(CR);
break;
case '\t":
writer.write(TAB);
break;
default:
if (character < 0x20) {
throw new IllegalArgumentException(Messages.getMessage(
"invalidXmlCharacter00",
Integer.toHexString(character),
xmlString.substring(0, i)));
} else if (character > 0xFFFF) {
writer.write((0xD7C0 + (character >> 10)));
writer.write((0xDC00 | character & 0x3FF));
} else {
writer.write(character);
}
break;
}
}