participate


Internationalization (I18N) - Print Characters in German
<<   Back to Forum  |   Give us Feedback
This topic has 8 replies on 1 page.
radhamadhuri2000
Posts:7
Registered: 9/9/03
Print Characters in German   
Sep 9, 2003 3:03 PM

 
Hi,

I have very simple problem. My aim is print the same characters as given in the input.

aCustomer.setCustomerNumber("????");
System.out.println(aCustomer.getCustomerNumber());

The Expected output: ????
Actual OutPut: ????

I have tried to set the key board in German mode. I have even set Locale to German( Locale.setDefault(Locale.GERMAN))

Please clarify how can I print the chars as given in the input.

Thanks

Radha
 
radhamadhuri2000
Posts:7
Registered: 9/9/03
Re: Print Characters in German   
Sep 9, 2003 3:05 PM (reply 1 of 8)  (In reply to original post )

 
Sorry, somehow the chars are not printed as I expected. It's aaaa with two dots on top of each a. The output was o with ~ on each o.
 
fsato4
Posts:1,844
Registered: 1/24/02
Re: Print Characters in German   
Sep 9, 2003 4:09 PM (reply 2 of 8)  (In reply to #1 )

 
The character 'ä' is (char)0xE4 ('\u00E4'), and 'õ' is (char)0xF5 ('\u00F5') in the Unicode. To see if the problem is of command line display or something other, first try file outputs or awt outputs. The command line dispay is concerned with the system setting not with Java codes.
 
Keith@Fujitsu
Posts:6
Registered: 9/9/03
Re: Print Characters in German   
Sep 9, 2003 5:14 PM (reply 3 of 8)  (In reply to #2 )

 
Your string has 16-bit characters. When you write to System.out, at some point it will be converted to 8-bit byte values. What conversion is being done. Check this by using "String.getBytes()" and check the individual byte values that come back.

The second part of the equation is where you are displaying these bytes (the command prompt) and what character set it is using to interpret the bytes.

Because you see something different, it is a fact that the character set that Java is converting the characters to is not the character set that you command window (or whatever) is using.
 
radhamadhuri2000
Posts:7
Registered: 9/9/03
Re: Print Characters in German   
Sep 11, 2003 10:58 AM (reply 4 of 8)  (In reply to #2 )

 
Thanks for your response. Yes, the output is being wriiten exactly into the file. But when I print it thru Dos command window, it does not dislplay "as is". If so, how can I set my window properties.
 
fsato4
Posts:1,844
Registered: 1/24/02
Re: Print Characters in German   
Sep 11, 2003 4:42 PM (reply 5 of 8)  (In reply to #4 )

 
Try the command

CHCP 850

where CHCP means "change codepage." Before doing that, you should simply enter the command

CHCP

and confirm the current codepage setting displayed.


(Though this is not about Java codes..)
 
radhamadhuri2000
Posts:7
Registered: 9/9/03
Re: Print Characters in German   
Sep 17, 2003 12:59 PM (reply 6 of 8)  (In reply to #5 )

 
No... Even though I set CHCP850, it does not print German chars as is. Can anybody help me, how can I ensure that I can print the exact German chars on my DOS window.

Thanks In advance
 
twegst
Posts:4
Registered: 2/26/98
Re: Print Characters in German   
Oct 29, 2004 8:31 AM (reply 7 of 8)  (In reply to #6 )

 
You may use an OutputStreamWriter and tell it to use a proper CodePage, like this (I decorate it with a PrintWriter in addition, so I can use the print() and println() methods):

PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out, codePage));

Writing text with umlauts, accents, and the like through pw should give the desired result.

It works fine on Win XP!

But I am having a problem puzzling me myself, related to the same topic!
Namely, I can't seem to do same on Win 98, running a JRE without the "charsets.jar" which appears to be a requirement:

Although when checking the codepage active in my console, I get told that "850" is the "active codepage", when creating the OutputStreamWriter in the way demonstrated above, I get an UnsupportedEncodingException thrown.
Would anybody know why that should be the case?

And: I included the two required classes
sun.io.ByteToCharCp850.class and
sun.io.CharToByteCp850.class

in a small .jar-File and put this in my classpath, but this seems to be ignored.

Any help would be greatly appreciated! I found several forum entries on this topic, but they all seem to end in the wild...

Regards,
Tillmann
 
goudvis2000
Posts:1
Registered: 1/12/05
Re: Print Characters in German   
Jan 12, 2005 3:55 AM (reply 8 of 8)  (In reply to original post )

 
Try playing with this class:

sun.io.ByteToCharConverter.getConverter("Cp850")

Works fine for me when handling an old latin-I DOS dbf file
 
This topic has 8 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 24
  • Guests : 134

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums