Problem regarding displaying the £ sign in a win32 console application  
Author Message
Speakafreaka





PostPosted: Visual C# Language, Problem regarding displaying the £ sign in a win32 console application Top

Hi, I'm trying to write what is really a very simple program, and am running into a stumbling block in regards to character output.

 

when I type theline:

     'cout << "£";'

 

it displays in the console window after compilation as:

     'u'

 

I was hoping someone could perhaps tell me why this happens, and suggest a solution   I've been scouting around online, and to my surprise found really very little information on how to do deal with this issue.

 

Thx



Visual C#16  
 
 
swemaniac





PostPosted: Visual C# Language, Problem regarding displaying the £ sign in a win32 console application Top

Try to go into your project settings and look for encoding or format or charset or something like that and try changing it.

Are you using a culture different from the English culture Try changing it. Also try to output the ASCII char number instead of the actual character.

Hope it helps
Cheers


 
 
Matthew Watson





PostPosted: Visual C# Language, Problem regarding displaying the £ sign in a win32 console application Top

It works fine in C#:



namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("£");
}
}
}



I think you're using C++...

In which case, you might want to post your message in the C++ forums.


 
 
RizwanSharp





PostPosted: Visual C# Language, Problem regarding displaying the £ sign in a win32 console application Top

I think it doesnot exist in ASCII so it wont display in DOS becuase DOS only supports ASCII but not Unicode...

Best Regards,

Rizwan



 
 
James Curran





PostPosted: Visual C# Language, Problem regarding displaying the £ sign in a win32 console application Top

As pointed out, the British pound sign isn't an offical part of the ASCII character codes (The "A" in "ASCII" is "American"). However, ASCII only defines code up to 127 (0x7f), so most fonts fill the extra space (128-255, 0x80-0xff) with other useful characters, with one usually being the British pound. However, the font maker do not agree on what code should be assigned to which characters.

So, the font you are writing you code in (I'll guess Courier New) defines 0xa3 as British Pound, however, the font used by the command window ("Terminal" by default), uses 0xa3 for Acute Lower U. The trick is finding a middle ground where they agree. You could print character 0x9C, which Terminal uses for Pound, or you can have the command prompt use Lucinda Console, which uses 0xA3 for pound, like most other fonts.