"");
String html = "ä Ä ö Ö < & > " +
"' "";
appendEntityAlphaTest("Test with one entity.", html,
"");
StringBuffer sbControl = new StringBuffer();
for (int ic = 0x80; ic <= 0x9f; ic++) {
sbControl.append((char)ic);
}
super.append("control(0)=\n" + sbControl.charAt(0) + "," + Integer.toHexString(sbControl.charAt(0)));
String control = sbControl.toString();
char[] cc = new char[sbControl.length()];
sbControl.getChars(0, cc.length, cc, 0);
String control2 = new String(cc);
super.append("control(0)=\n" + control.charAt(0) + "," + Integer.toHexString(control.charAt(0)));
super.append("control2(0)=\n" + control2.charAt(0) + "," + Integer.toHexString(control2.charAt(0)));
String cvControl = control;
try {
cvControl = new String(control.getBytes("ISO-8859_1"), "Cp1252");
} catch (UnsupportedEncodingException e) {
super.append("Conversion error for win contol string.");
}
super.append("cvControl(0)=\n" + cvControl.charAt(0) + "," + Integer.toHexString(cvControl.charAt(0)));
String ncontrol = EncodingUtil.replaceSpChars(cvControl, true, false,
false, false);
super.append("converted cvControl,ncontrol=\n" + ncontrol.charAt(0) + "," + Integer.toHexString(ncontrol.charAt(0)));
StringBuffer sbTst = new StringBuffer();
StringBuffer sbRes = new StringBuffer();
appendHashTest("Iso entities", EncodingUtil.getConvIso88591(), sbTst, sbRes);
// Convert from ISO to iso
String cvRes = EncodingUtil.replaceSpChars(sbRes.toString(),
false, false, false, false);
StringBuffer sbwTst = new StringBuffer();
StringBuffer sbwRes = new StringBuffer();
appendHashTest("cp1252 entities", EncodingUtil.getConvCp1252(), sbwTst, sbwRes);
// Convert from windows to windows
String cvwRes = EncodingUtil.replaceSpChars(sbwRes.toString(),
true, false, true, false);
appendEntitySpTest("Test with iso conv to iso midp phone.",
sbRes.toString(), false, false, false, cvRes);
// Convert from windows to windows . Given that windows uses
// ISO control characters, it should not match the other encoding.
appendEntitySpTest("Test with win conv to iso midp phone.",
sbwRes.toString(), true, false, false, cvRes);
appendEntitySpTest("Test with win conv to win midp phone.",
sbwRes.toString(), true, true, false, cvwRes);
// Convert from ISO to windows. Given that windows supports
// the ISO characters, it should match other decoding too.
appendEntitySpTest("Test with iso conv to windows midp phone.",
sbRes.toString(), false, true, false, cvwRes);
appendEntitySpTest("Test with iso sponly conv to iso midp phone.",
control, false, false, false, control);
// Convert from windows to windows . Given that windows uses
// ISO control characters, it should not match the other encoding.
appendEntitySpTest("Test with win sponly conv to iso midp phone.",
control, true, false, false, control);
appendEntitySpTest("Test with win sponly conv to win midp phone.",
control, true, true, false, control);
// Convert from ISO to windows. Given that windows supports
// the ISO characters, it should match other decoding too.
appendEntitySpTest("Test with iso sponly conv to windows midp phone.",
control, false, true, false, control);
String[] isoSp = EncodingUtil.getIsoSpecialEntities();
char[] isoSpVals =
{'-', // en dash
'-', // em dash
'\'', // left single quotation mark
'\'', // right single quotation mark
'\'', // single low-9 quotation mark
'\"', // left double quotation mark
'\"', // right double quotation mark
'\"'}; // double low-9 quotation mark
Hashtable isoConv = new Hashtable();
EncodingUtil.initEntVals(isoConv, isoSp, isoSpVals);
StringBuffer sbSp = new StringBuffer();
StringBuffer sbSpRes = new StringBuffer();
appendHashTest("Iso special entities", isoConv, sbSp, sbSpRes);
}