Java SMS PDU格式-如何提取消息部分

Java SMS PDU格式-如何提取消息部分,java,sms,gsm,pdu,Java,Sms,Gsm,Pdu,如何从SMS PDU提取消息 我需要从SMS PDU接收消息。当我使用一些在线服务时,它们工作得很好。例如,这里--来自PDU的消息0791448720003023240DD0E474D81C0EBB01000011011315214000BE474D81C0EBB5DE3771B是diafaan.com 我发现一些SMS PDU Java实现需要进行PDU->Text转换,但它们似乎没有像我预期的那样工作,因为我没有从整个PDU中提取消息部分(换句话说,我没有从SMSC中剪切服务信息),所以我

如何从SMS PDU提取消息

我需要从SMS PDU接收消息。当我使用一些在线服务时,它们工作得很好。例如,这里--来自PDU的消息
0791448720003023240DD0E474D81C0EBB01000011011315214000BE474D81C0EBB5DE3771B
diafaan.com


我发现一些SMS PDU Java实现需要进行
PDU->Text
转换,但它们似乎没有像我预期的那样工作,因为我没有从整个PDU中提取消息部分(换句话说,我没有从SMSC中剪切服务信息),所以我如何在Java上做到这一点?或者仅仅是一个算法也会有很大的帮助。谢谢

最后我使用了SMSLib库:

            //String resultMessage = ...
            Pdu pdu = new PduParser().parsePdu(resultMessage);
            byte[] bytes = pdu.getUserDataAsBytes();
            String decodedMessage;
            int dataCodingScheme = pdu.getDataCodingScheme();
            if (dataCodingScheme == PduUtils.DCS_ENCODING_7BIT) {
                decodedMessage = PduUtils.decode7bitEncoding(null, bytes);
            } else if (dataCodingScheme == PduUtils.DCS_ENCODING_8BIT) {
                decodedMessage = PduUtils.decode8bitEncoding(null, bytes);
            } else if (dataCodingScheme == PduUtils.DCS_ENCODING_UCS2) {
                decodedMessage = PduUtils.decodeUcs2Encoding(null, bytes);
            } else {
                log.error("Unknown DataCodingScheme!");
                ...
            }

它可以做得更好-在
PduUtils中有一个
getDecodedText
方法