| Author |
Character array of primitive elements initialization
|
Shiva Mohan
Ranch Hand
Joined: Jan 05, 2006
Posts: 465
|
|
Hi, key[0]=128; key[1]=32765; key[2]='Z'; key[3]=65535; It is giving the output ? ? Z ?. I thought,byte and short types are implicitly conver to char.It converted.But Why,It is giving ? for everything.Is char arrays,using ASCII codes for numbers from 0 to 127.What about the numbers from 128 to 65535.Please share your knowledge. Thanks, Shiva
|
 |
Rusty Shackleford
Ranch Hand
Joined: Jan 03, 2006
Posts: 490
|
|
|
For character values outside of the ascii range, you will likely get jibberish, unless you specify a locale
|
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
|
 |
Shiva Mohan
Ranch Hand
Joined: Jan 05, 2006
Posts: 465
|
|
|
Thank you for your reply.
|
 |
Rusty Shackleford
Ranch Hand
Joined: Jan 03, 2006
Posts: 490
|
|
I know it wasn't all that helpful. Here is a link that might be more useful then my vague blathering http://java.sun.com/j2se/1.4.2/docs/guide/intl/fontprop.html. There are some good tutorials at java.sun.com, a search should help you out if you need to display other types of characters.
|
 |
Vlado Zajac
Ranch Hand
Joined: Aug 03, 2004
Posts: 244
|
|
The characters outside 0-127 range are converted to ? by PrintStream's print method. You can either use a Writer to convert the characters to correct encoding or DataOutputStream to write the 2-byte value or char. If you want to print the value as a number (with PrintStream), than cast it to int.
|
 |
 |
|
|
subject: Character array of primitive elements initialization
|
|
|