BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-14-2008, 10:36 AM   #1 (permalink)
New Member
 
Join Date: Jun 2008
Model: 324
PIN: N/A
Carrier: at&t
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Convert Unicoded text into corresponding character returns by getPayLoadText() method

Please Login to Remove!

Hi,

I want to read and parse the data when SMS message is arrived or sent. i read successfully by the method getPayloadText() of TextMessage class when message is in text format and less then 160 characters.

but if the message contians special characters like '&','_' etc it gives me its unicode character

for e.g it returns '\u0011' of '_' and '\u0000' of '@' character respectively.

please help me how do i convert it into its corresponding character becuase i don't know how many special characters will be in message.

Please let me know any sample code or tutorial

Thanks
Sohail
Offline  
Old 07-14-2008, 01:09 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

There is a special String class constructor that accepts a byte[] array and an encoding string, like "UTF-8".

public String(byte[] bytes,
String enc)
throws UnsupportedEncodingException

Take a look at the String class in the API reference.
Offline  
Old 07-15-2008, 10:14 AM   #3 (permalink)
New Member
 
Join Date: Jun 2008
Model: 324
PIN: N/A
Carrier: at&t
Posts: 10
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, but i have already converted string from getPayloadText() method. if i convert with getBytes("UTF-8"), it will convert the converted character (returns from getPayloadtext() like (test\u0011sohail) into bytes.it doesn't converted into its actual representation of Unicode character.

so i want the routine which will convert unicode character into UTF-8 string

Regards
Sohail
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.