Welcome!

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

Reply
Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Sms character problem

Hi,

 

I am using Message Listener to listen to incoming SMS messages, my problem is when the incoming sms messages contains "@" character the messages does not display after that.  For example when I send SMS with "I am @ witn another @" the messages comes as "I am". I use the follow code but of no help.

 

 

if (originalMessage instanceof TextMessage)
{
TextMessage tm = (TextMessage) originalMessage;
msg = new String(tm.getPayloadText().getBytes(),"UTF-8");

}
else if (originalMessage instanceof BinaryMessage)
{

byte[] data = ((BinaryMessage) originalMessage).getPayloadData();

// convert Binary Data to Text
msg = new String(data, "UTF-8");

}

 

 thanks,

 

yosoh

 

--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Sms character problem

The '@' symbol gets wacked during the SMS encode/decode process and gets turned into a char 0 (null).

 

 

 

 

 

Developer
Posts: 213
Registered: ‎07-18-2008
My Device: Not Specified

Re: Sms character problem

[ Edited ]

thanks. I reproduced what you have said.  Is there any solution to this problem ?? Does that mean I have check my message for '@' everytime and act accordingly. Also, are there any more characters that might cause trouble?

 

yosoh

Message Edited by yosoh on 12-04-2008 03:20 PM
--------------------------------------------------
problemSolved() ? kudosPlease():kudosPlease();
Highlighted
Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Sms character problem

here is some code i wrote a few years ago for my sms2mail application (which is still available for free at my former company, http://cms.bfinet.de/BFI2006/bfi_produkte/sms2mail/bfi_sms2mail.asp).
it converts the german umlauts back from their crippled appearances of their 7 bit encoding.
i don't know if it is possible to send sms in UTF-16.
maybe this encoding table is helpful, it is only available in the german wikipedia as it seems, but the raw data are the interesting things anyhow.
http://de.wikipedia.org/wiki/SMS-Kodierung

if(txtNewEmail.charAt(i) == '~')
txtNewEmail.setCharAt(i, 'ü');
if(txtNewEmail.charAt(i) == '^')
txtNewEmail.setCharAt(i, 'Ü');
if(txtNewEmail.charAt(i) == '|')
txtNewEmail.setCharAt(i, 'ö');
if(txtNewEmail.charAt(i) == '\\')
txtNewEmail.setCharAt(i, 'Ö');
if(txtNewEmail.charAt(i) == '{')
txtNewEmail.setCharAt(i, 'ä');
if(txtNewEmail.charAt(i) == '[')
txtNewEmail.setCharAt(i, 'Ä');
if(txtNewEmail.charAt(i) == '')
txtNewEmail.setCharAt(i, 'ß');
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter