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: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Unicode Reply

Hi,

 

I am trying to connect to my server..

 

It gives me reply in Unicodes..how to decode that..

 

3051i12BDFC90B2489CEF

 

Thanks

Ekansh

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Unicode Reply

any help!!!

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Unicode Reply

Is that the actual sequence of characters (that is, '\', 'u', '0', etc.)? Or is whatever is rendering the string escaping non-printable characters? In other words, is the first character '\\', or is it '\u0004'?

 

The question marks later in the string suggest to me that a byte sequence has already been converted to characters, but using the wrong character encoding.




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Unicode Reply

hi,

 

Thanks for the reply.

 

Its '\u0004'

 

3052iE2F43C20291240D2

 

Thanks

Ekansh

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unicode Reply

I think Ted has already identified the problem.

 

Remember that the IO Stream does not send characters, it sends bytes.  Something in your code converts this to characters.  It appears this conversion is incorrect.  Have a look at the code you use to convert from bytes to String and make sure the process you use here is the reverse of whatever your server is doing when it converts to the byte stream.

Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Unicode Reply

hi,

 

Peter thanx for the reply.

 

Yeah i m getting in bytes and converting it into string and i get the above(img) output

reply = new String(buf, 0, count);

 

 

The server is made in C#.net ..its uses BinaryReader and BinaryWriter.

 

And there is no API for binary read/write AFAIK.

 

I am stuck here and not able to proceed forward.

 

Thanks

Ekansh

 

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Unicode Reply

Sorry I have no idea what BinaryWriter does, though I suspect someone on this forum probably does.  That said, It would surprise me if it was not well documented, and I'm sure you could reverse engineer it.  So don't give up just yet.  In fact Google it, someone has probably already tried to read a BinaryWriter file in java and knows what to do. 

Developer
Posts: 468
Registered: ‎08-07-2009
My Device: Curve, Bold, Storm
My Carrier: Blackberry Developer

Re: Unicode Reply

hi Peter,

 

Thanks for all your effort. Smiley Happy

 

I am googling for it. If i get something..i will let you know.

 

Thanks

Ekansh

----------------------------------------------------------
feel free to press the kudos button on the left side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: Unicode Reply

I suspect that you just need to use

reply=new String(buf, 0, count, "UTF-8");




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Highlighted
Developer
Posts: 1,807
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.3.2.858, Z10 (STL100-3)-10.3.1.2576, Z30 (STA100-5)-10.3.1.2582, Passport (SQW100-1)-10.3.1.2576, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Unicode Reply

Well he said it is in Unicode and it looks to be in Unicode so you would use "UTF-16BE" or "UTF-16" instead of "UTF-8".

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.