twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Character Coding issue -Special Characters received as "?"

Buchafwe opened this issue · comments

Hi Team;

We are using cloudhopper-smpp, facing an issue which might be related a character coding on both deliver_sm from smsc and submit_sm from esme. e.g "é" is received as "?"

Code snippet of my deliver_sm is :
byte[] shortMessage = (DeliverSm)pduRequest.getShortMessage();
body = new String(shortMessage);

Any assistance will be appreciated.

You should normally never use the single byte[] argument String constructor since it's dependent on the plarform's default character encoding. Please explicitly specify a character set, e.g. using Java 7's StandardCharsets.UTF_8. For GSM or other character sets, you can use any of cloudhopper-smpp's com.cloudhopper.commons.charset.Charset implementations, like e.g. GSMCharset or UCS2Charset instead of the String constructor. The PDU should have a field specifying the character set.

Thanks for the prompt response Stela. Let me try to implement this using character sets offered by cloudhopper smpp, will update.

Thanks Stela, works well using com.cloudhopper.commons.charset.Charset and com.cloudhopper.commons.charset.CharsetUtil