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
Contributor
ashokbb_narra
Posts: 13
Registered: ‎02-26-2013
My Device: blackberry curve 8520

How to convert string with charset as utf-16 and encoding type as base64 to normal readable string in BB

Hi i am getting the string  as follws 

Content-Type: text/plain; charset="utf-16"
Content-Transfer-Encoding: base64

//5wAGEAcwBzAHcAbwByAGQADQAKAA==

//5wAGEAcwBzAHcAbwByAGQADQAKAA==:is the origional string of type base 64 with charset as
"utf-16"

Now How to convert this to normal string in BB..
Developer
peter_strange
Posts: 19,612
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to convert string with charset as utf-16 and encoding type as base64 to normal readable string in BB

You read the bytes into a byte array, then use the String constructor to turn this into a normal Java String

 

For example:

 

byte [] inputBytes = .....

String inputString

try {

inputString = new String(inputBytes, "UTF-16");

} catch (Exception e) {

// Should not happen as UTF-16 is a supported character set

}