I to have exactly the same problem the only way i have found around it is to do the following...
import java.io.*; //Need this..
public class poundSign{
public static void main(String[] arg){
try {
OutputStreamWriter osw = new OutputStreamWriter
(System.out, "Cp850"
PrintWriter out = new PrintWriter (osw);
System.out.println("£" //prints out a funny sign
Caveat: I am assuming that you are using a Windows/DOS system, so YMMV.
From the PrintStream javadoc: All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. (Emphasis mine)
By default, all DOS consoles use MS-DOS Codepage 437 (US) as the default character encoding.
If you change this to Microsoft Windows Codepage 1252 (ANSI) using the "chcp" command (e.g., "c:\> chcp 1252", you'll get the desired output from:
public class PoundSign{
public static void main(String[] pArgs) {
char thisChar = 0xA3;
System.out.println(thisChar);
}
}
Writer w = new OutputStreamWriter( System.out, "Cp437" );
PrintWriter out = new PrintWriter (w);
out.println("Pound sign: \u00a3"
out.flush();
Alternatively you can define the encoding on the java command line.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.