BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-14-2009, 08:46 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default tcp: send special chars

Please Login to Remove!

hi,
some time ago i have asek how to decode special chars on a tcp connection (TCP with , , , ,...).

now i want to send special chars, so that an windows-service could read the string without any errors. so i have tried this here:
Code:
  byte[] theByteArray = ((String)sendList.elementAt(0)).getBytes();
                                String strSendString = new String(theByteArray,"UTF8");
                                os.write(strSendString.getBytes());
                                System.out.println("gesendet: "+strSendString);
                                sendList.removeElementAt(0);
                                os.flush();
but i always get an ? instead of an ,, or .... the output in the console is correct.

so now i developed a desktop application in vb.net, which also sends a UTF8-decoded string. and there i've git no problems with:
Code:
 myBuffer = System.Text.Encoding.UTF8.GetBytes(Data)
                               myTCPClient.GetStream.Write(myBuffer, 0, myBuffer.Length)
                        myTCPClient.GetStream.Flush()
so maybe someone could help me...? is there an option on the bes oder on the BB?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 04-14-2009, 04:26 PM   #2 (permalink)
New Member
 
Join Date: Apr 2009
Model: -
PIN: N/A
Carrier: -
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

How about this?

Code:
byte[] theByteArray = ((String)sendList.elementAt(0)).getBytes("UTF-8");
os.write(theByteArray);
System.out.println("gesendet: "+new String(theByteArray, "UTF-8"));
sendList.removeElementAt(0);
os.flush();

Last edited by klyubin : 04-14-2009 at 04:26 PM. Reason: Fixed a typo
Offline  
Old 04-15-2009, 04:13 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi...
erm... i have tried it, but... no but. it works fine

thanks =)

kind of regards hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  




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