private String encode(String input, char[] immutable) {
ParameterValidation.throwIllegalArgExceptionIfNull(input, "String");
Writer sw = new StringWriter();
CharWriter charWriter = new WriterCharWriter(sw);
safeEncode(input.toCharArray(), 0, input.length(), charWriter, immutable);
return sw.toString();
}