twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
Other
381 stars 357 forks source link

Character Coding issue -Special Characters received as "?" #121

Closed Buchafwe closed 8 years ago

Buchafwe commented 8 years ago

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.

stela commented 8 years ago

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.

Buchafwe commented 8 years ago

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

Buchafwe commented 8 years ago

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