The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How to define unicode character? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How to define unicode character?" Watch "How to define unicode character?" New topic

How to define unicode character?

lauren bai

Joined: Apr 08, 2005
Posts: 18
I write a class and want to print character "PI".

class test {
public static main(String args[]) {
char c = '\u03c0';

Output: ?

I don't know why I get "?" instead of the character "PI".

Thank you in advance.

SCJP (In Progress)
Peter Gravestock

Joined: Apr 17, 2005
Posts: 2
Is this a problem with the device you are outputing the data to? Perhaps it can not handle UNICODE characters, only ASCII. Maybe if you create a small Swing program and output the test there, I am sure it will display better.
Saurabh Khanna
Ranch Hand

Joined: Apr 03, 2005
Posts: 30
I am getting the same problem. Chaning the DOS console font to Lucid Console still does'nt fix the problem even though Lucid Console is supposed to display these chars properly as per spec?
Raghu Shree
Ranch Hand

Joined: Mar 18, 2005
Posts: 143
Its work fine in Eclipse like editor and all other font which is support unicode chars. Change the screen font which is support unicode and run again this code.

Raghu J<br />SCJP 1.4<br /> <br />The Wind and waters are always<br />on the side of the ablest navigators.<br /><a href="" target="_blank" rel="nofollow">SCJP Group</a><br /><a href="" target="_blank" rel="nofollow">SCWCD Group</a>
I agree. Here's the link:
subject: How to define unicode character?
It's not a secret anymore!