"\u0627\u0644\u062d\u0627\u0633\u0648\u0628 \u002b\u0020\u0627\u0646\u062a\u0631\u0646\u064a\u062a";
byte[] beBytes = source.getBytes("UnicodeBig");
byte[] leBytes = source.getBytes("UnicodeLittle");
CharsetDetector det = new CharsetDetector();
CharsetMatch m;
det.setText(beBytes);
m = det.detect();
if (! m.getName().equals("UTF-16BE")) {
errln("Encoding detection failure: expected UTF-16BE, got " + m.getName());
}
det.setText(leBytes);
m = det.detect();
if (! m.getName().equals("UTF-16LE")) {
errln("Encoding detection failure: expected UTF-16LE, got " + m.getName());
}
// Jitterbug 4451, for coverage
int confidence = m.getConfidence();
if(confidence != 100){
errln("Did not get the expected confidence level " + confidence);
}
int matchType = m.getMatchType();
if(matchType != 0){
errln("Did not get the expected matchType level " + matchType);
}
}