This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hello I would like to print extended ascii characters(characters between 127 and 255). Unfortunately I am not able to get the corresponding ascii character symbols for the following values 129,141,143,144,157. I am getting the correct values for all the other numbers, except for these numbers where a ? is returned. for( int i=127;i < 256;i++) { byte[] data = new byte[1]; data[0]= (byte)i; System.out.println("The character " + new String(data)); } Could any one tell me where I went wrong ? Please do help me with an idea of getting the values for the missed numbers? Thanking you in advance Regards Samuel
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
There's more than one "extended ASCII" out there. Probably the default encoding on your machine is different from what you are expecting. Instead use the String constructor that allows you to specify an encoding: <code><pre> System.out.println(new String(data, "US-ASCII")); System.out.println(new String(data, "ISO-LATIN-1"));</pre></code> For comparison, you can find out the name of the default encoding on your system with <code><pre> System.out.println("Default: " + new InputStreamReader(System.in).getEncoding());</pre></code> More info on encoding can be found here and here.