Send Unicode SMS via SMPP

I want to send sms iwth Unicode characters via SMPP (JSMPP library). I know that for data encoding there should be 8, and sms length should be 70 characters. But when I try this, I get SMS with Chinese characters. 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 that, I get a message with Chinese characters. What's wrong?

+3
source share
2 answers

Do not convert the string to a hexadecimal string and do not use this encoding:

GeneralDataCoding dataCoding = new GeneralDataCoding(false, true, MessageClass.CLASS1, Alphabet.ALPHA_UCS2);

Receive bytes:

byte[] textByte = text.getBytes("UTF-16BE");

In this example, you can send sms with this encoding UCS2.

+2
source

It should be

byte[] textByte = text.getBytes("UTF-16BE");

HexUtil - This is a red herring.

+3
source

All Articles