阿拉伯语与cloudhopper SMPP

时间:2013-11-24 17:04:40

标签: java smpp

我正在尝试使用CloudHopper lib使用SMPP发送阿拉伯语短信,但我遇到的问题是字符出现(?????)

        msg = "\u0627\u062E\u062A\u0631 \u0627\u0644\u062C\u0647\u0629";

        byte[] shortMessage = CharsetUtil.encode(msg, CharsetUtil.NAME_UTF_8);
        SubmitSm submit0 = new SubmitSm();

        // add delivery receipt
        submit0.setRegisteredDelivery(SmppConstants.REGISTERED_DELIVERY_SMSC_RECEIPT_REQUESTED);

        submit0.setSourceAddress(new Address((byte)5, (byte)1, VIVA_SENDER_ID));
        submit0.setDestAddress(new Address((byte)1, (byte)1, mobileNumber));
        Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, shortMessage, "message_payload");
        submit0.setOptionalParameter(tlv);
        submit0.setDataCoding((byte)8);
        submit0.setOptionalParameter(tlv);
        SubmitSmResp submitResp = session0.submit(submit0, 10000);
        result=submitResp.getResultMessage();

是否有使用CloudHopper lib发送阿拉伯字符的示例/方式?

1 个答案:

答案 0 :(得分:2)

我解决了它,我们只需要用以下代码编码阿拉伯语短信:

byte[] shortMessage = CharsetUtil.encode(msg, CharsetUtil.CHARSET_UCS_2);