Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing unicode character

 
Manoj Kumar Jain
Ranch Hand
Posts: 198
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Just to see some Unicode character I wrote a small code to print the Unicode character from 128 to 255.



when I run the code the output was as below


it prints "?" up to 159, prints space for 160 and after that it prints some symbol.
So I am wondering why its printing "?" for many of the values. do we need to install fonts in my system to get these symbols printed ?

 
Winston Gutkowski
Bartender
Pie
Posts: 10426
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manoj Kumar Jain wrote:it prints "?" up to 159, prints space for 160 and after that it prints some symbol.
So I am wondering why its printing "?" for many of the values. do we need to install fonts in my system to get these symbols printed ?

Not sure, but it's unlikely that you'll get the output on a standard console or command line program (although it may be possible in some Unix terminal emulators).

Have you tried displaying via a Java Swing Component, such as a JTextField? I'm no GUI expert, but I suspect it'd be much more likely to handle "abnormal" characters than a standard 'term'-type display.

Winston
 
Manoj Kumar Jain
Ranch Hand
Posts: 198
Java Linux Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Winston, There is no GUI component. I am running this piece of code in eclipse with windows environment, I can see this output on the eclipse console.
however now I tried to run it one the command prompt, and output was the same.

[edit]
However when I look for the values of these Unicode 128-159 it says that it's a <control> kind of but have some symbol to represent.
below is the link:

http://www.ssec.wisc.edu/~tomw/java/unicode.html#x0000

So is that the reason that these are not being printed ? not sure..
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15364
40
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure that the console output in Eclipse or on the command prompt is using a font that contains the Unicode characters that you want to display? Not all fonts (especially the default font used for the command prompt window) contain all Unicode characters, and you'll see question marks for missing characters.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic