aspose file tools*
The moose likes Beginning Java and the fly likes Printing unicode character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing unicode character" Watch "Printing unicode character" New topic
Author

Printing unicode character

Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 193

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 ?


Do not wait to strike till the iron is hot; but make it hot by striking....
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8233
    
  23

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Manoj Kumar Jain
Ranch Hand

Joined: Aug 22, 2008
Posts: 193

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

Joined: Aug 16, 2005
Posts: 14348
    
  22

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing unicode character