Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 12
Registered: ‎08-25-2011
My Device: Bold 9780
My Carrier: Vodafone

TextMessage - payload encoding - what is it?

I have a TextMessage object being given to be from an SMS.sendMessage(). The TextMessage object has getAddress and getPayloadText. What is the encoding of this string? 


I am assuming it is GSM 7bit encoded text, however when i decode the getBytes() it fails and int he place of a Euro symbol i get a ?, this is the same for any characters outside of the normal a-z, 1-9 and basic punctuation style text.


I need to wrap up the payload and send it elsewhere to another server. So i was planning to encode the string as base64 to make it safe for me transport. Currently through i cannot get the payload text in a usable format that I can rely on.


How do i get this into UTF-8, or UTF-16BE format with the GSM 7bit characters preserved. I have tried the new String(sms.getPayloadText(), "UTF-16BE") however this also fails to give me the text as seen on screen. i.e with foreign characters. When decoded it return ???? for the characetrs outside of its character set.






Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: TextMessage - payload encoding - what is it?

Sorry, I am not familiar with the problem.  However I would have thought that using getBytes("UTF-8"), and then base64 encoding the resultant bytes would have given you a text String that would get through OK.  Do the reverse at the other end.  Will this work for you?

Posts: 10
Registered: ‎10-23-2009
My Device: Not Specified

Re: TextMessage - payload encoding - what is it?

I've just unpacked (no pun intended) something similar, but in reading SMS data from the datagram. The data was packed in GSM 7-bit and there was some conversion required. I tried all the standard character set encoders that come with BB, to no avail. I then stumbled upon this reference [http://www.wrankl.de/JavaPC/SMSTools.html] which was quite useful for PDU and SMS encoding/decoding.... G'luck!

Posts: 1
Registered: ‎08-30-2013
My Device: Curve 9300
My Carrier: Telcel?

Re: TextMessage - payload encoding - what is it?

Did anybody had luck on this?. i'm desperate now Smiley Sad