nsDetector det = new nsDetector(nsPSMDetector.ALL);
boolean isAscii = det.isAscii(bytes,bytes.length);
// DoIt if non-ascii and not done yet.
if (!isAscii)
det.DoIt(bytes,bytes.length, false);
charsets = det.getProbableCharsets();
det.DataEnd();
if (isAscii) return "ASCII";
if (charsets.length == 0) return null;