if (split.length > 1) {
lang = split[1];
}
try {
CharsetDetector det = new CharsetDetector();
byte[] bytes;
//if (enc.startsWith("UTF-32")) {
// UTF32 utf32 = UTF32.getInstance(enc);
// bytes = utf32.toBytes(testString);
//} else {
String from = enc;
while (true) {
try {
bytes = testString.getBytes(from);
} catch (UnsupportedOperationException uoe) {
// In some runtimes, the ISO-2022-CN converter
// only converts *to* Unicode - we have to use
// x-ISO-2022-CN-GB to convert *from* Unicode.
if (from.equals("ISO-2022-CN")) {
from = "x-ISO-2022-CN-GB";
continue;
}
// Ignore any other converters that can't
// convert from Unicode.
return;
} catch (UnsupportedEncodingException uee) {
// Ignore any encodings that this runtime
// doesn't support.
return;
}
break;
}
//}
det.setText(bytes);
checkMatch(det, testString, enc, lang, id);
det.setText(new ByteArrayInputStream(bytes));
checkMatch(det, testString, enc, lang, id);
} catch (Exception e) {
errln(id + ": " + e.toString() + "enc=" + enc);
e.printStackTrace();
}