Can't get the extra escape characters to work in GSM 7-bit alphabet.

2k views Asked by At

I am sending to the SMSC for example this string "[ ]" which encodes to a byte[] in hex "1B3C201B3E" according to GSM 7-bit alphabet where the "1B" is the character for the extra 10 characters and 3C is "[" and 3E is "]" accordingly but it won't print print correctly on my cellphone which prints " < >" because it prints "1B" as space and the "<" = "3C" and ">" = "3E". Also, it can't print any of the weird characters "èéùìòÇØøÅå€ÆæßÉ@¤¡ÄÖÑܧ¿äöñüà" but works fine with Greek chars. Is it my error or it has something to do with the specific SMSC? Is the byte[] correct or not?

2

There are 2 answers

0
David Hofmann On

You need to choose one data_coding (or encoding scheme) based on the kind of characters that you need to use. Page 136 of the SMPPv4 protocol spec document shows you what data codings you can use.

Then for example, if you choose UCS2 you can make msg.getBytes("UCS2") and set your datacoding to 8 and that will make any UCS2 representable characters shown well in the phone.

I think that if you need to use GSM 7-bit alphabet you need to set datacoding to 1, then you need a gsm 7-bit alphabet encoder, from string to bytes, I think that is not available in standard jdk

0
aleung On

You let data_coding to default(0), which means you don't specify the alphabet using in the pdu . SMSC will decode it using the default configured alphabet on SMSC side.

In your case, it looks like that the SMSC isn't configured to use GSM 7-bit as default. The possible default alphabet is Latin (ISO-8859-1), because in Latin, 0x3C is "<" and 0x3E is ">", 0x1B is not printable so it's translated to space.

So you could try to encode your message in ISO-8859-1.