org.jivesoftware.smack.bosh.MessageBodyDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smack-ece Show documentation
Show all versions of smack-ece Show documentation
Library to connect to Cisco Enterprise Chat and Email (ECE) chat interface which is a modified version of XMPP over BOSH standard.
The newest version!
package org.jivesoftware.smack.bosh;
import org.apache.commons.text.StringEscapeUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
/**
* Decodes/unescapes special characters in ECE's message body
*/
public class MessageBodyDecoder {
/**
* Decodes the specified text replacing escaped characters with their unescaped representations
*
* @param text to decode
* @return decoded results
*/
public String decode(String text) throws UnsupportedEncodingException {
text = URLDecoder.decode(text, "UTF-8");
text = text.replaceAll("\\^([a-z0-9,2])","%$1");
text = URLDecoder.decode(text, "UTF-8");
text = StringEscapeUtils.unescapeXml(text);
return text;
}
}