n.setTagNames(tagNames);
n.setTagGuids(tagGuids);
}
if (loadContent) {
QTextCodec codec = QTextCodec.codecForLocale();
codec = QTextCodec.codecForName("UTF-8");
String unicode = codec.fromUnicode(query.valueString(17)).toString();
// This is a hack. Basically I need to convert HTML Entities to "normal" text, but if I
// convert the < character to < it will mess up the XML parsing. So, to get around this
// I am "bit stuffing" the < to &< so StringEscapeUtils doesn't unescape it. After
// I'm done I convert it back.
StringBuffer buffer = new StringBuffer(unicode);
if (Global.enableHTMLEntitiesFix && unicode.indexOf("&#") > 0) {
unicode = query.valueString(17);
//System.out.println(unicode);
//unicode = unicode.replace("<", "&_lt;");
//unicode = codec.fromUnicode(StringEscapeUtils.unescapeHtml(unicode)).toString();
//unicode = unicode.replace("&_lt;", "<");
//System.out.println("************************");
int j=1;
for (int i=buffer.indexOf("&#"); i != -1 && buffer.indexOf("&#", i)>0; i=buffer.indexOf("&#",i+1)) {
j = buffer.indexOf(";",i)+1;
if (i<j) {
String entity = buffer.substring(i,j).toString();
int len = entity.length()-1;
String tempEntity = entity.substring(2, len);
try {
Integer.parseInt(tempEntity);
entity = codec.fromUnicode(StringEscapeUtils.unescapeHtml4(entity)).toString();
buffer.delete(i, j);
buffer.insert(i, entity);
} catch (Exception e){ }
}