baos.write(data, start, data.length - start);
data = baos.toByteArray();
if (!charset.equalsIgnoreCase("UTF-8")) {
ByteBuffer input = ByteBuffer.wrap(data);
Charset cs = Charset.forName(charset);
CharBuffer cb = cs.decode(input);
Charset utf8 = Charset.forName("UTF-8");
ByteBuffer output = utf8.encode(cb);
data = output.array();
}
return TidyParser.parse(new ByteArrayInputStream(data));