Newt6398
asked on
Java print £ sign
Hi i'm new to the java world i'm studying it as part of my computing course and am having difficulty with getting the '£' character to display. I am using the Javac compiler and only making DOS based programs at the moment. Any help will be greatly appreciated.
Thank you
Craig.
Thank you
Craig.
ASKER
Here is my code:
import java.util.Scanner;
class Hello
{
public static void main(String args[])
{
System.out.print("\u00A3"+ " Hello");
}
}
I'm just getting a U symbol with an accent above? Have tried changing the number. I know when you're in MS-DOS you can hold ALT+156 to get the £ character is this in any relation?
import java.util.Scanner;
class Hello
{
public static void main(String args[])
{
System.out.print("\u00A3"+
}
}
I'm just getting a U symbol with an accent above? Have tried changing the number. I know when you're in MS-DOS you can hold ALT+156 to get the £ character is this in any relation?
>> I know when you're in MS-DOS you can hold ALT+156 to get the £ character is this in any relation?
Are you able to get it this way?
If not, you're java program won't be able to neither.
It's a matter of code page...
Are you able to get it this way?
If not, you're java program won't be able to neither.
It's a matter of code page...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Na still not working. The table gives a value of \u00A3 this will give the accented U symbol when i run the program. However ALT+156 in MS-DOS gives me the £ symbol only when i convert to use it in the program as in \u009C it gives me a question mark when i run the program. I tried changing the font still no joy i'm afraid.
ASKER
PS. I have also noticed that there is no reference to the £ sign on the ASCII table is this of significance??
See the instructions i posted above - they work fine for me
ASKER
yes the chcp thing worked. however is it possible to do this chcp from my java code so no user has to mess about doing it themselves. Thanks so far anyway.
>>is this of significance??
Not really. What is of significance is what encoding is being used in your OS and console
Not really. What is of significance is what encoding is being used in your OS and console
>>however is it possible to do this chcp from my java code
It's not really practicable. Better to use a gui component to output pound signs
It's not really practicable. Better to use a gui component to output pound signs
>> is it possible to do this chcp from my java code
I don't know if it is a good idea to do that.
I wouldn't like a program that tampers with my code pages...
I don't know if it is a good idea to do that.
I wouldn't like a program that tampers with my code pages...
ASKER
okay well thanx all. Points goto CEHJ for gettin it working. Cheers
:-)
-----------------------
http://www.unix.org.ua/orelly/java-ent/servlet/appd_01.htm