CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Re: British keyboard £ in console app

    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.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #17
    Join Date
    Jun 2006
    Posts
    46

    Re: British keyboard £ in console app

    thanks, it is quite a small project though.
    Attached Files Attached Files

  3. #18
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Re: British keyboard £ in console app

    Well, this is quite interesting. I changed your code to be this:-

    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
    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'.

    Obviously, Windows and DOS use different values for the '£' symbol. DOS uses character 156 and Windows uses character 163.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  4. #19
    Join Date
    Jun 2006
    Posts
    46

    Re: British keyboard £ in console app

    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 ?

  5. #20
    Join Date
    Aug 2005
    Location
    Netherlands, The
    Posts
    2,184

    Re: British keyboard £ in console app

    as i sayd there is some api to fix this i just dont know what it is

  6. #21
    Join Date
    Jun 2006
    Posts
    46

    Re: British keyboard £ in console app

    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.

  7. #22
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: British keyboard £ in console app

    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.

    You can also get very strange effects when importing a text file with accented characters, that was created with an old DOS editor.

  8. #23
    Join Date
    Jun 2006
    Posts
    46

    Re: British keyboard £ in console app

    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.

  9. #24
    Join Date
    Jul 2002
    Location
    Portsmouth. United Kingdom
    Posts
    2,727

    Re: British keyboard £ in console app

    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 £)

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured