BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 10-30-2008, 07:37 AM   #1
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default TCP with ä, ö, ü, ß,...

Please Login to Remove!

hey there,
i've got a tcp connection and i want to display some names or something.
now i've git the problem, that an the place for an ä stands a symbol or something.

i send the data to the BB as an ASCII string, so i have to encrypte this string on BB again, but how?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 10-30-2008, 07:51 AM   #2
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Default

Looks like a character encoding issue. The BlackBerry uses UTF-8 by default - check and see what kind of encoding is being used on the other end of the socket. Probably 8859 if it is a Windows system.

You'll need to take the byte array and convert to string with the correct encoding, or change the encoding on the other end to UTF-8.

See API docs for String:

public String(byte[] bytes,String enc)
Offline  
Old 02-27-2009, 04:58 AM   #3
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default

ok, i have tried this one here:
PHP Code:
 do {
                        
ch = (byte)is.read();
                        
sb.append((charch);
                    } while (
is.available() > 0);
                         
String myErg = new String(sb.toString().getBytes(),"UTF8");
                            
myBuffer += myErg
all 'ä', 'ö', 'ü' and 'ß' are displayed as '??'...
i have tried UTF-8, UTF8 and ASCII.

the sender is a windows-service, sending in ASCII...

maybe someone can help me

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after

Last edited by hibbert; 02-27-2009 at 05:08 AM..
Offline  
Old 03-01-2009, 02:40 PM   #4
nanika
Knows Where the Search Button Is
 
Join Date: Mar 2008
Location: Paris, France
Model: None
PIN: N/A
Carrier: None
Posts: 36
Default

You must set the "source" encoding, which is probably ISO-8859-1...
Offline  
Old 03-10-2009, 06:59 AM   #5
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default

hi,
ok, and what if i can't change the source encoding? What should i do then? is there an option which i can change on the BES or on the BB?

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 03-10-2009, 01:37 PM   #6
nanika
Knows Where the Search Button Is
 
Join Date: Mar 2008
Location: Paris, France
Model: None
PIN: N/A
Carrier: None
Posts: 36
Default

As a matter of fact, I think your code is wrong before the "new String()" bit : when you "append" the read byte to "sb" (which, I assume, is a string buffer), the wrong conversion has already happened.

What you need to do is read the data in a byte array and convert this byte array to a String.
Offline  
Old 03-11-2009, 05:43 AM   #7
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default

Ok, thanks, but that won't work, because of this one here:
i have printed out every char, and look what happens:
i get this string: 613 Z??hler
and here are the char-numbers:
6 --> 54
1 --> 49
3 --> 51
 --> 23
Z --> 90
? --> -61
? --> -92
h --> 104
l --> 108
e --> 101
r --> 114

so the "ä" as got two numbers. so i can convert the inputstream at any position, and it won't work, because the "ä" has got two characters.

so what can i do??

thanks hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 03-11-2009, 01:51 PM   #8
nanika
Knows Where the Search Button Is
 
Join Date: Mar 2008
Location: Paris, France
Model: None
PIN: N/A
Carrier: None
Posts: 36
Default

Characters on 2 bytes just mean it's an UTF-8 encoding. And imply that you will have to explicitly set the encoding when doing the conversion.

That does not change a thing about what I wrote above: fill a byte array with the text and do the conversion on the whole array. You don't have any other option except decoding the UTF-8 chars yourself.
Offline  
Old 03-12-2009, 06:47 AM   #9
hibbert
Thumbs Must Hurt
 
Join Date: May 2007
Location: berlin, germany
Model: 8310
PIN: N/A
Carrier: vodafone
Posts: 163
Default

hi,
ok, but how do i create a dynamed byte-array? and how do i convert this one to a new string?

thanks again.
hibbert
__________________
My English is so bad, that makes me nobody so quickly after
Offline  
Old 03-13-2009, 04:48 AM   #10
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

ByteArrayOutputStream
__________________
java developer, Devinto, hamburg/germany
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US picture

NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US

$304.07



New Factory Sealed AB 1747-L532 SER E SLC 500 5/03 CPU Processor Unit 1747L532 picture

New Factory Sealed AB 1747-L532 SER E SLC 500 5/03 CPU Processor Unit 1747L532

$320.76



FANUC A860-2000-T301 PULSECODER picture

FANUC A860-2000-T301 PULSECODER

$325.00



1000W Stainless Steel Welding Bead Processor,Brush Type Weld Cleaning Machine picture

1000W Stainless Steel Welding Bead Processor,Brush Type Weld Cleaning Machine

$199.27



OMRON C200H-CPU21-E PLC OVERNIGHT SHIPPING picture

OMRON C200H-CPU21-E PLC OVERNIGHT SHIPPING

$269.75



New Allen-Bradley AB 1764-LRP SER C MicroLogix1500 Processor PLC 1764LRP picture

New Allen-Bradley AB 1764-LRP SER C MicroLogix1500 Processor PLC 1764LRP

$381.26







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