in doxia-core/src/main/java/org/apache/maven/doxia/util/HtmlTools.java [224:272]
public static String escapeHTML(final String text, final boolean xmlMode) {
if (text == null) {
return "";
}
int length = text.length();
StringBuilder buffer = new StringBuilder(length);
for (int i = 0; i < length; ++i) {
char c = text.charAt(i);
switch (c) {
case '<':
buffer.append("<");
break;
case '>':
buffer.append(">");
break;
case '&':
buffer.append("&");
break;
case '\"':
buffer.append(""");
break;
default:
if (xmlMode) {
if (c == '\'') {
buffer.append("'");
} else {
buffer.append(c);
}
} else {
if (c <= ASCII) {
// ASCII.
buffer.append(c);
} else {
buffer.append("&#x");
if (isHighSurrogate(c)) {
buffer.append(Integer.toHexString(toCodePoint(c, text.charAt(++i))));
} else {
buffer.append(Integer.toHexString(c));
}
buffer.append(';');
}
}
}
}
return buffer.toString();
}