This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Java in General and the fly likes How do I print extended ascii characters in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How do I print extended ascii characters in Java " Watch "How do I print extended ascii characters in Java " New topic

How do I print extended ascii characters in Java

Samuel Thomas

Joined: Nov 08, 2000
Posts: 4
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
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
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"));
For comparison, you can find out the name of the default encoding on your system with
<code><pre> System.out.println("Default: " + new InputStreamReader(;</pre></code>
More info on encoding can be found here and here.

"I'm not back." - Bill Harding, Twister
Have you checked out Aspose?
subject: How do I print extended ascii characters in Java
jQuery in Action, 3rd edition