Unicode短信发送(smpp)

时间:2019-03-04 08:52:17

标签: java unicode sms message smpp

为了发送Unicode短信,我将其分成67个字节,如下所示:

java.nio.charset.Charset charset = java.nio.charset.Charset.forName("UTF-16LE"); 
List<SmsMessage> gRoutingSubMessageList = new ArrayList<SmsMessage>();
int splitMessageId = (int) (System.currentTimeMillis() % 256);
int st = 0, st2 = 0, j = 0, k = 0;
byte[] dataByte = messageC.getData().getBytes(charset);
    //split it 
while (j < dataByte.length) {
    k++;
    SmsMessage m;
    if (k == 1)
        m = message;
    else
        m = (SmsMessage) messageC.clone();
    j = st + 67 > dataByte.length ? dataByte.length : st + 67;
    if (dataByte[j - 1] == 27)
        st2 = 65;
    else
        st2 = 66;   

    m.setData(new String(dataByte, st, st + st2 > dataByte.length ? dataByte.length - st : st2, charset));
    m.setCurrentSegment(k);
    m.setSplitMessageId(splitMessageId);
    gRoutingSubMessageList.add(m);
    st = st + st2;                       
}

但是收到的邮件已损坏,有什么解决方法吗?

1 个答案:

答案 0 :(得分:0)

使用132代替67,使用131代替65