This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The Unicode value for the pound sign is \u00A3. In decimal, this is 163, which typically represents an accented "u" (�) in ascii extended. This is what you're seeing.
How these characters display depends on the environment. In my XP Command window, a println of "�xyz" displays �xyz. However, in Eclipse, this displays as �xyz. So although you're seeing � in the Command window, I expect that you would see � in a Java GUI.
Unfortunately, I don't know how to get the pound sign to display in the Command window. The extended ascii value for the pound sign is usually 156, so I expected char p = 156 to display as �, but it displays a question mark instead
The term "extended ascii" is pretty much useless nowadays. Do not trust anything or anyone which talks about "extended ascii" as if it means something. We're long past the point when ascii was enough, and there's more than one form of "extended ascii". You need to find out exactly what the default encoding is on your system - that's what your system speaks. Unfortunately Sun did not bother to create a simple method to do this, even though it's really useful information for you to have when debugging encoding problems. Try this:
I suspect that the encoding on your system will turn out to be one in which £ cannot be represented. Not all characters can be represented on all systems by default. Have you ever seen £ printed in a command window on your system? You may need to abandon System.out.println() and instead send your output to something that knows what a £ is. Good candidates for this would be a web browser (where you can represent £ as "£" - that's how I posted this) or some sort of JTextComponent (which understands Unicode much better than System.out does). Alternately, you may be able to reset your platform default encoding to something which supports £. Let us know what the default encoding is, and what kind of system you're on, and we may be able to help better. [ February 27, 2005: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
Joined: Oct 04, 2004
Firstly, many thanks for your response - much appreciated.
The operating system I am on is Windows 2000
I tried your suggestion and received the following error:
Microsoft Windows 2000 [Version 5.00.2195] (C) Copyright 1985-2000 Microsoft Corp.
If you don't see £ in your Windows console, try changing the font of the window. Click the window's icon (left side of title bar), select Properties, and switch to Font tab. I use Lucida Console (I find it's the easiest on my eyes) and can see the £ when I type Alt-156.
Originally posted by Jim Yingst: The term "extended ascii" is pretty much useless nowadays...
Yeah, that's why I qualified it with words like "typically" and "usually." I referenced extended acsii only because I think it explains why the accented u is appearing, but I didn't go down the path of different extended sets.
From a practical standpoint -- assuming we're stuck with a Windows console -- I suggest abandoning the symbol and using the acronym, "GBP." [ February 28, 2005: Message edited by: marc weber ]