This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hi plz help regarding ASCII values  RSS feed

 
Amit Sharma
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone
i am dealing with ASCII values and i want to print ASCII value of 0 to 255 but my program doesn't show coresponding ASCII characters of 129 to 160. rest values get printed.i am using jdk1.4.
my program is
class amit{
public static void main(String args[]){
int a=0;
while(a<=255){
System.out.println(a+(char)a);
a++;}
}
}

for 129 to 160 it simply shows " ? " . while these have something different ASCII for them. for refrence plz visit http://www.lookuptables.com/
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, ASCII does not have characters beyond 127. So what you get after that depends on your operating system.

Secondly, where does your standard out go to? If it's some kind of console, be aware that many consoles can display ASCII only (which -see above- is not defined beyond 127).

I like this character table, as it correlates ASCII with the various extensions above 127, and also shows corresponding HTML entities.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not "advanced." Since there are character set and display issues involved, I think I/O and Streams is a reasonable place for it. Off it goes...
 
Paul Clapham
Sheriff
Posts: 22482
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And Java uses the Unicode character set for its chars. The first 128 code points (U+0000 to U+007F) of Unicode are ASCII. The next 128 code points (U+0800 to U+00FF) are called "Latin-1" and you can see them here:

http://www.unicode.org/charts/PDF/U0080.pdf

Note that the ones you complain about converting to question marks are control characters that don't have a visual representation.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!