hi all, when i try to
cout << "£";
it outputs a char 'u' with dash above ( code -93 ).
i found "£" code is -100, but it's awkaward to type "(char)-100" every time :-).
are there any project settings to fix it ?
thanks for help.
Printable View
hi all, when i try to
cout << "£";
it outputs a char 'u' with dash above ( code -93 ).
i found "£" code is -100, but it's awkaward to type "(char)-100" every time :-).
are there any project settings to fix it ?
thanks for help.
try '£' instead of "£"
i have tried. same result.
First of all, are you actually based in the UK? You might have forgotten this but in the bad old days of DOS, each country had a country code and code page for console support. The code page for the UK was 850 if I remember correctly. Not sure about the country code but it might have been 44. If these don't match your machine, you won't see pound signs until you make them match. There was a driver called keyboard.sys that provided the appropriate symbols. In fact, even Windows has a similar concept.
Open up a console window on your screen, then hold down the shift key whilst hitting the number 3. Do you see pound signs?
i forgot to add i am using VS6 sp6.
yes, i am in uk.
in both: "cmd.exe" and "command.com" the "£" is rendered correctly while shift + 3.
As far as I can tell, the '£' sign is character 163 (0x00A3)
163 on my machine is 'ú'
156 on my machine is '£'
i meant -100 is "£", because char is signed byte
Strange.... so did you find it eventually?
1. did you check font
2. did you check the language in system
3. did you check language of keyboard
4. did you try char& = 163? or char = 156?
left alt + num key 163 on my machine is 'ú'
left alt + num key 156 on my machine is '£'
above shows in any program( notepad, wordpad, pure console command line, with every font.
char c = 163;
cout << c;
renders 'ú', so it is consistent.
all settings in system are set to english(uk).
this problem shows only in a console app, any other application ( for example mfc with GUI ) works fine.
i heard some guy say, you had to change some settings in console.
but im not sure though..
look here:
http://www.lookuptables.com/extend.gif
http://www.lookuptables.com/
it shows axactly as u say
try ALT+163 in your IDE does it show up a £?
it is like in the table. so this part is ok, i guess.
in IDE it works like in notepad; alt+163 is 'ú', as table says.
i can't see any console settings for that, is there a conf file ?
I've lost track of the current situation. Are you saying that it now works when you specify character 156 - or are you saying that it should work but it doesn't?
If it's still not working, why don't you zip up the project and post it here so that someone else can see if the problem is reproducable? When zipping up a project, don't bother to include the Debug or Release folders. Also, depending on the size of the project you might need to leave out any files that the compiler will recreate (such as clw, aps, ncb, opt & plg files).
you mentioned that
"the '£' sign is character 163 (0x00A3)"
but according to the http://www.lookuptables.com/extend.gif - it is not.
so my system works exactly as table says, and this does not have to be a project.
simple cout << "£" will output 'ú' in VS6 console app, in GUI app it will output correctly '£'.
I got character 163 from Windows internal character map (you can find it from the Seacrh menu by searching for 'Character map').
It looks like you'll need to post your project if you want any further help with this.
thanks, it is quite a small project though.
Well, this is quite interesting. I changed your code to be this:-
and I put a break point at the return(0); line. The first cout prints the expected text in my DOS window. The second version prints the expected text to string 's' when I examine the string in my debugger. When the cin line was reached, 'c' was equal to -93 (character 163). I then typed the £ sign on my keyboard. This displayed the correct symbol in my console window and gave me a result of -100 for 'c'.Code:#include <iostream.h>
#include <stdio.h>
int main()
{
char c;
char s[25];
c = -100;
sprintf(s, "Pound sign = %c\n", c);
cout << s;
c = '£';
sprintf(s, "Pound sign = %c\n", c);
cout << s;
cin >> c; // Just wait for a bit
return 0;
} // end main
Obviously, Windows and DOS use different values for the '£' symbol. DOS uses character 156 and Windows uses character 163.
Thank you for your time and info, which is a surprise to me, as i thought that "win32 console app" is a windows app, not dos, but it shows that it is true only partially ?
as i sayd there is some api to fix this i just dont know what it is
:(
i could not find this api though. what i found , someone said that in order to use '£' you should use unicode. this seems too much of a hassle to me, as i do programming only in english.
If you check the Character Map utility you will find that the Terminal font uses a different mapping to the rest of the Windows fonts with the Ú at 165 and the £ at 156. This is probably the font that Windows uses as default for console apps and was the mapping for DOS.
If you set the font for the console window to Lucinda Console then I suspect all would be ok. :thumb:
You can also get very strange effects when importing a text file with accented characters, that was created with an old DOS editor. :eek:
yes, it looks like terminal uses "terminal" and "lucida console" font, however the character set is probably "dos: western europe", so setting it to "lucida console" makes no difference, as unicode and dos mappings differ for this font.
You're right, I just checked with a console app, running once with the default font, changing the font to Lucinda Console and then running again. I got the ú both times. Interestingly, if I copy the text from the console and paste elsewhere it stays as a ú. (ie. It doesn't change to a £)