4

I am unable to print the euro symbol. The program I am using is below.

I have set the character set to codepage 1250 which has 0x80 standing for the euro symbol.

Program
=======

#include <stdio.h>
#include <locale.h>

int main()
{
    printf("Current locale is: %s\n", setlocale (LC_ALL, ".1250"));
    printf("Euro character: %c\n", 0x80);
    getchar();
    return 0;
}

Output
======
Current locale is: English_India.1250
Euro character: ?

Other details
=============
OS: Windows Vista
Compiler: vc++ 2008 express edition

Abhijith Madhav
  • 2,748
  • 5
  • 33
  • 44

3 Answers3

3

Read this: http://www.columbia.edu/~em36/wpdos/eurodos.html

There are sections, which could help you a lot:

  • Display the euro-symbol in full-screen DOS and command consoles in Windows NT, 2000, or XP
  • Display the euro symbol in DOS and command console windows in Windows 2000 and XP (built-in support for TrueType fonts)
  • Display the euro in DOS and command consoles in Windows 2000 and XP (bitmap and TrueType fonts)
SLA80
  • 743
  • 9
  • 10
  • 2
    This is the correct answer, the console font has to be changed. In addition, you must call SetConsoleCP() to switch the console code page, setlocale() does not do this. – Hans Passant Dec 28 '09 at 14:25
  • Thanks. You have to set the console's input and output code page. i.e SetConsoleCP(), SetOutputConsoleCP(). Refer to http://msdn.microsoft.com/en-us/library/ms683169%28VS.85%29.aspx http://msdn.microsoft.com/en-us/library/ms686013%28VS.85%29.aspx – Abhijith Madhav Dec 28 '09 at 15:06
3

the 0x80 char is falsely stated as the euro sign, it is the Padding Char. See here: http://bugs.mysql.com/bug.php?id=28263

If I remember correctly it must something around 0x120, try printing in a for loop from 120 to 130

Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
1
#include <stdio.h>

int main()
{
 printf("\u20AC");
return 0;
}

I used GCC compiler and this works fine. The output is: €


This only work with C++ and C99

Community
  • 1
  • 1
Michel Gokan Khan
  • 2,525
  • 3
  • 30
  • 54
  • I wanted to print '€' using a non-unicode character set. The issue was with the windows console as pointed out by SLA80 above. Thanks anyway. – Abhijith Madhav Dec 28 '09 at 15:09