/**
* INTERNAL:
*/
protected void writeValue(String value, boolean escapeChars, boolean isAttribute, OutputStream os) {
if (escapeChars) {
CharacterEscapeHandler escapeHandler = marshaller.getCharacterEscapeHandler();
if (escapeHandler != null) {
try {
CharArrayWriter out = new CharArrayWriter();
escapeHandler.escape(value.toCharArray(), 0, value.length(), isAttribute, out);
byte[] bytes = out.toString().getBytes();
outputStreamWrite(bytes);
out.close();
} catch (IOException e) {
throw XMLMarshalException.marshalException(e);