If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
ankitagrawalwinit
Posts: 16
Registered: ‎10-31-2011
My Device: 9800
My Carrier: Software Developer

Character Encoding

Hi,

I want to encode characters. Original word is "Niafunké" and while parsing i'm getting "Niafunké".

Please tell me solution to get original word.

 

Thanks.

Please feel free to press like button, if u satisfy with solution.

AnkitRockks
Please use plain text.
Trusted Contributor
Albert_Anks
Posts: 151
Registered: ‎06-17-2010
My Device: Curve 8900
My Carrier: Vodafone

Re: Character Encoding

hi ankitagrawalwinit,

You set the encoding here:

sb.append(new String(data1, 0, len));

Most servers will give you UTF-8, but you should know that. If it was UTF-8 you woudl do this:

sb.append(new String(data1, 0, len, "UTF-8"));
----------------------------------------------------------
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.
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Character Encoding

You said:

"while parsing ...."

What sort of parsing are you doing?  And how do you get the data to be parsed? 

 

This might influence the best way to get around this issue. 

Please use plain text.
Contributor
ankitagrawalwinit
Posts: 16
Registered: ‎10-31-2011
My Device: 9800
My Carrier: Software Developer

Re: Character Encoding

From server side, i am getting xml in following standards:

 

<xml version="1.0" encoding="utf-16">..

Please feel free to press like button, if u satisfy with solution.

AnkitRockks
Please use plain text.
Contributor
ankitagrawalwinit
Posts: 16
Registered: ‎10-31-2011
My Device: 9800
My Carrier: Software Developer

Re: Character Encoding

I am using SAX parsing..
Please feel free to press like button, if u satisfy with solution.

AnkitRockks
Please use plain text.
Developer
pradeep_ch
Posts: 543
Registered: ‎12-23-2010
My Device: Z10
My Carrier: Airtel

Re: Character Encoding

Hi Ankit,

 

See this link which may helpfull.

 

http://www.rgagnon.com/javadetails/java-0307.html

 

Thanks.

Please use plain text.
Developer
tklanilkumar
Posts: 206
Registered: ‎02-22-2011
My Device: BB TORCH & 9800
My Carrier: idea

Re: Character Encoding

hi ankit and pradeep

check this link also

http://blackberry.svn.wordpress.org/tags/1.4.1/src/com/wordpress/utils/StringUtils.java


Thanking you
*****************************************************************************
* Give kudos when you like it
* Mark it as a solution if it fixes your issue
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: Character Encoding

Either pass the stream through to the parser, or read the bytes in and pass the byte array to the parser using ByteArrayInputStream.  Don't try t o process it to text yourself.  There is not need, the XML parser will convert it for you and it will use the correct encoding because it has been told what to expect. 

Please use plain text.