我正在通过 smack api 制作聊天应用程序。当我发送包含此字符'
的消息时,输出为
消息==女士
输出==
嘛
'
是
这是代码
StringEscapeUtils.unescapeHtml((new String(ch, start, length).replace("'", "`").replace("'", "'")));
这是代码
DefaultHandler handler = new DefaultHandler() {
@Override
public void startDocument() throws SAXException {
}
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
for (int i = 0; i < attributes.getLength(); i++) {
if (attributes.getLocalName(i).equalsIgnoreCase("from")) {
from = attributes.getValue(i);
break;
}
}
....
}
@Override
public void characters(char ch[], int start, int length) throws SAXException {
String str = StringEscapeUtils.unescapeHtml((new String(ch, start, length)));
switch (elementType) {
case 1:
msg = str;
break;
...
default:
...
break;
}
//
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
}
@Override
public void endDocument() throws SAXException {
}