M
mfeher
Hi all,
I am getting back into Java programming after a long layoff and now
that I'm doing it everyday, I'm remembering the things I enjoyed about
it and the things that I find maddening. I'm trying to write a
simple program to both test my old skills as well as develop code for
use later, when I will need it on a later project.
Right now I'm simply trying to display a Unicode character in the
Eclipse output window. I have a full-up WinXP system with a ton of
fonts (more on that in a moment) but don't seem to see what is wrong
with my program.
I never did much with Unicode years before and never had it succeed for
me then, either, if I recall correctly. But I don't think the
process/requirements are that hard:
- Have Unicode fonts installed
- Use the correct encoding in the Java output stream
- Look up the correct character(s) in the Unicode tables
Here's the program as it stands now (one file called Main.java):
import java.io.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws
UnsupportedEncodingException {
String unicodeMessage = "\u03B2";
// Print out a Unicode character
System.out.println("We attempt to print out the Greek character
beta:");
PrintStream output = new PrintStream(System.out, true, "UTF-8");
output.println(unicodeMessage);
}
}
Here's the output I get:
We attempt to print out the Greek character beta:
β
Please, can someone spot the (probably simple) error in my
setup/coding? Thanks!
Mike
I am getting back into Java programming after a long layoff and now
that I'm doing it everyday, I'm remembering the things I enjoyed about
it and the things that I find maddening. I'm trying to write a
simple program to both test my old skills as well as develop code for
use later, when I will need it on a later project.
Right now I'm simply trying to display a Unicode character in the
Eclipse output window. I have a full-up WinXP system with a ton of
fonts (more on that in a moment) but don't seem to see what is wrong
with my program.
I never did much with Unicode years before and never had it succeed for
me then, either, if I recall correctly. But I don't think the
process/requirements are that hard:
- Have Unicode fonts installed
- Use the correct encoding in the Java output stream
- Look up the correct character(s) in the Unicode tables
Here's the program as it stands now (one file called Main.java):
import java.io.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) throws
UnsupportedEncodingException {
String unicodeMessage = "\u03B2";
// Print out a Unicode character
System.out.println("We attempt to print out the Greek character
beta:");
PrintStream output = new PrintStream(System.out, true, "UTF-8");
output.println(unicodeMessage);
}
}
Here's the output I get:
We attempt to print out the Greek character beta:
β
Please, can someone spot the (probably simple) error in my
setup/coding? Thanks!
Mike