I want to receive UniCode SMS from jSMPP.
If Data Coding is 8, I want to convert it to Unicode symbols.
For this I use HexUtil.convertBytesToHexString
function.
But it doesn't convert it correctly. How can I convert this string?
@Override
public void onAcceptDeliverSm(DeliverSm arg0)
throws ProcessRequestException {
if (MessageType.SMSC_DEL_RECEIPT.containedIn(arg0.getEsmClass())) {
// Deliver SM
} else {
byte[] data = arg0.getShortMessage();
String text = null;
if (arg0.getShortMessage() != null) {
if (arg0.getDataCoding() == (byte) 8) {
text = HexUtil.convertBytesToHexString(data, 0,
data.length);
} else {
text = new String(data);
}
}
System.out.println("Text -> " + text);
}
}
Try this way (use you own encoding detection):
also u can try UTF-16LE, UTF-16BE encoding, if UTF-16 dont display correct