通过 SMPP 发送 Unicode 短信
我想通过 SMPP(JSMPP 库)发送带有 unicode 字符的短信。我知道数据编码必须是 8 &短信长度为 70 个字符。但是当我尝试这个时,我收到带有中文符号的短信。这是我的代码:
ESMClass esmClass = new ESMClass();
GeneralDataCoding coding = new GeneralDataCoding(8)
String text = "üöğçşə ƏIÖĞŞÇÜ";
String p = HexUtil.convertStringToHexString(text);
byte[] textByte = HexUtil.convertHexStringToBytes(p);
String messageId = session.submitShortMessage("CMT",TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN,"1111", TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN, "phone_number", esmClass,
(byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT),
(byte) 0, coding, (byte) 0, textByte);
之后我收到带有中文符号的消息。怎么了?
I want to send sms iwth unicode characters via SMPP (JSMPP library). I know that Data Encoding must be 8 for it & sms length is 70 character. But when I try this, I get sms with Chinese symbols. Here is my code:
ESMClass esmClass = new ESMClass();
GeneralDataCoding coding = new GeneralDataCoding(8)
String text = "üöğçşə ƏIÖĞŞÇÜ";
String p = HexUtil.convertStringToHexString(text);
byte[] textByte = HexUtil.convertHexStringToBytes(p);
String messageId = session.submitShortMessage("CMT",TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN,"1111", TypeOfNumber.INTERNATIONAL,
NumberingPlanIndicator.UNKNOWN, "phone_number", esmClass,
(byte) 0, (byte) 1, timeFormatter.format(new Date()), null,
new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT),
(byte) 0, coding, (byte) 0, textByte);
After this I get message with Chinese symbols. What is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应该是
HexUtil
在这里是一个转移注意力的事情。It should be
HexUtil
is a red herring here.不要将字符串转换为十六进制字符串 &使用此数据编码而不是:
获取字节:
此示例为您提供使用此字符集 UCS2 发送短信。
Don't convert string to hex string & use this data coding instead of that:
Get bytes:
This sample gives you send sms with this charset UCS2.