Below is a Java program to print a unicode character to windows console
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
public class PrintUnicodeChar {
public static void main (String[] argv) throws UnsupportedEncodingException {
String unicodeMessage = "\u00A3"; // Pound sign
PrintStream out = new PrintStream(System.out, true, "UTF-8");
out.print(unicodeMessage);
}
}
I have selected Lucida Console as the font and set the codepage to 65001.
The output I get is £�
If I print the pound sign three times using "\u00A3\u00A3\u00A3"
, the output becomes £££�£. Printing characters with higher unicode value outputs more � making it more garbled.
Here is another string "\u00A3\n\u00A3\u00A3\n\u00A3\u00A3\u00A3\n\u00A3\u00A3\u00A3\u00A3\n\u00A3\u00A3\u00A3\u00A3\u00A3\n"
The output is
£
££
£££
££££
£££££
�£
£££££
�££
�
What is happening? Is it a problem with the Windows 7 terminal? How to prevent the additional characters from printing?