Java Forum / First Aid / March 2006
Re: Can't Get Pound Sign
Chris Clarke - 21 Mar 2006 00:03 GMT When I display the character set from '\u0000' to '\u00FF' there is no £ (pound) sign. Character '\u0023' appears as # in my console window. My Keyboard is set to English
(United Kingdom). When I type a £ at the command prompt, it appears as a £, but when I
try to write a Java statement such as:
System.out.println("£");
and run it, it appears as a u with an acute (Hex character '\u00A3'). I tried using the
cmd command but it doesn't recognise this command. What, if anything, can I do?
PS I can get the £ sign in frames, but I would like to be able to use it in the CLI. Can anybody help?
 Signature Visit http://uk.geocities.com/brilliant_moves/ for chess, Mastermind, Tetris and many more original Applets with source code. Enjoy!
Roedy Green - 21 Mar 2006 00:12 GMT On Mon, 20 Mar 2006 23:03:36 +0000 (UTC), "Chris Clarke" <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted someone who said :
>When I display the character set from '\u0000' to '\u00FF' there is no à >(pound) sign. >Character '\u0023' appears as # in my console window. My Keyboard is set to >English In Unicode, British pound sign £ is \u20a4'
That is the coding scheme you use internally. You will read an InputStreamReader to convert from whatever encoding you are using now to translate.
see http://mindprod.com/applets/fileio.html for sample code.
When your run wassup what does it say your default encoding is?
see http://mindprod.com/applets/wassup.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Chris Clarke - 21 Mar 2006 00:35 GMT Thanks for ur suggestion. I tried System.out.println('\u20A4'); but just got a ? (question mark)
 Signature Visit http://uk.geocities.com/brilliant_moves/ for chess, Mastermind, Tetris and many more original Applets with source code. Enjoy!
> On Mon, 20 Mar 2006 23:03:36 +0000 (UTC), "Chris Clarke" > <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted [quoted text clipped - 18 lines] > > see http://mindprod.com/applets/wassup.html Roedy Green - 21 Mar 2006 00:36 GMT On Mon, 20 Mar 2006 23:35:12 +0000 (UTC), "Chris Clarke" <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted someone who said :
>Thanks for ur suggestion. I tried > System.out.println('\u20A4'); >but just got a ? (question mark) see http://mindprod.com/jgloss/encoding.html
you need some background.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Chris Clarke - 21 Mar 2006 00:53 GMT I'm using the Java 2 Platform Standard Edition, Version 1.5.0 (1.5.0_06); I've written many Java applications, some of them CLI apps, most of them using frames, also a few Applets of varying complexity; I've read David Heller's "Ground-up Java", and also "Core Java Volume 1"; I've also gleaned ideas from Java source code freely available on the net.
It's just this blessed £ (pound) sign I'm having difficulty with on the command line interface. As a simple example,
import java.awt.*; import java.text.*; import java.util.*;
public class CurrencyTest3 { // see p59 Core Java Vol 1 static double x=100; public static void main(String[] args) { NumberFormat formatter = NumberFormat.getCurrencyInstance(Locale.UK); System.out.println(formatter.format(x)); System.out.println("£"); } }
The output of this program? U guessed it: <strange u symbol here>100.00 <strange u symbol here> Does the (American) Java SDK/JRE not support English symbols?
 Signature Visit http://uk.geocities.com/brilliant_moves/ for chess, Mastermind, Tetris and many more original Applets with source code. Enjoy!
> On Mon, 20 Mar 2006 23:35:12 +0000 (UTC), "Chris Clarke" > <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted [quoted text clipped - 7 lines] > > you need some background. Roedy Green - 21 Mar 2006 01:09 GMT On Mon, 20 Mar 2006 23:53:42 +0000 (UTC), "Chris Clarke" <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted someone who said :
>It's just this blessed à(pound) sign I'm having difficulty with on the >command line interface. As a simple example, As I said, you need to some background to understand the problem. You won't run Wassup for me so I can't help further.
Again, if you want to crack this you will need to understand encodings. It is NOT like C. http://mindprod.com/jgloss/encoding.html
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Chris Clarke - 21 Mar 2006 01:20 GMT Thanks for your help. I don't know what Wassup is, but I will look into encodings; possibly some online tutorials or peruse my local library. Once again, thank you. I'll give this a break now!
 Signature Visit http://uk.geocities.com/brilliant_moves/ for chess, Mastermind, Tetris and many more original Applets with source code. Enjoy!
> On Mon, 20 Mar 2006 23:53:42 +0000 (UTC), "Chris Clarke" > <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted [quoted text clipped - 8 lines] > Again, if you want to crack this you will need to understand > encodings. It is NOT like C. http://mindprod.com/jgloss/encoding.html Roedy Green - 21 Mar 2006 01:40 GMT On Tue, 21 Mar 2006 00:20:15 +0000 (UTC), "Chris Clarke" <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted someone who said :
>Thanks for your help. I don't know what Wassup is, but I will look into >encodings; possibly some online tutorials or peruse my local library. Once >again, thank you. I'll give this a break now! I gave you the URL earlier http://mindprod.com/applets/wassup.html
The problem is fonts and encodings interact in not entirely simple way. If you want to solve this without learning that background material, you will have to follow instructions carefully.
So run wassup and report what it says about your file.encoding
Then run http://mindprod.com/applets/fontshower.html and see if any of your installed fonts fail to show the pound sign correctly.
 Signature Canadian Mind Products, Roedy Green. http://mindprod.com Java custom programming, consulting and coaching.
Oliver Wong - 21 Mar 2006 23:36 GMT > On Tue, 21 Mar 2006 00:20:15 +0000 (UTC), "Chris Clarke" > <chris.clarke2004@btinternet.com> wrote, quoted or indirectly quoted [quoted text clipped - 11 lines] > > So run wassup and report what it says about your file.encoding In case it isn't clear, when Roedy tells you to "run Wassup", he means you should use your web browser to navigate to the page http://mindprod.com/applets/wassup.html, which contains an embedded applet called "Wassup". That's the applet he's trying to get you to run.
When I went to that page, it asked me if I would trust the applet, and I said "No". The applet managed to gain SOME information about my system, but it did not say anything about encoding, so I guess I was supposed to say "Yes" to see the encoding info. The output when I run the applet looks like this:
<quote> browser = sun.plugin browser.version = 1.1 file.separator = \ java.class.version = 49.0 java.specification.name = Java Platform API Specification java.specification.vendor = Sun Microsystems Inc. java.specification.version = 1.5 java.vendor = Sun Microsystems Inc. java.vendor.url = http://java.sun.com/ java.version = 1.5.0_06 </quote>
And so on.
- Oliver
James Westby - 21 Mar 2006 02:05 GMT > I'm using the Java 2 Platform Standard Edition, > Version 1.5.0 (1.5.0_06); [quoted text clipped - 23 lines] > <strange u symbol here> > Does the (American) Java SDK/JRE not support English symbols? $ java5 -version java version "1.5.0_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing) $ java5 CurrencyTest3 £100.00 £
So, it does support it.
What OS are you running under? What encoding is your .java file using? What is your platforms default encoding?
Many people have problems when then default encoding cannot handle the characters they are trying to output, and so specifying a specific encoding solves the problem. I have had a problem before that occured because my files did not have the characters in them that I thought they had, and a combination of Eclipse and my platform were hiding this problem until I moved the files to a different server, upon which the encoding problem manifested itself.
James
James Westby - 21 Mar 2006 02:13 GMT > I'm using the Java 2 Platform Standard Edition, > Version 1.5.0 (1.5.0_06); [quoted text clipped - 23 lines] > <strange u symbol here> > Does the (American) Java SDK/JRE not support English symbols? $ java5 -version java version "1.5.0_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09) Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing) $ java5 CurrencyTest3 £100.00 £
So, it does support it.
What OS are you running under? What encoding is your .java file using? What is your platforms default encoding?
Many people have problems when then default encoding cannot handle the characters they are trying to output, and so specifying a specific encoding solves the problem. I have had a problem before that occured because my files did not have the characters in them that I thought they had, and a combination of Eclipse and my platform were hiding this problem until I moved the files to a different server, upon which the encoding problem manifested itself.
James
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|