Installation guide
4-8
Bull S.A.May 25th, 1999
9.3 Usage of ”locale” in C programs
9.3.1 IBM–1252: Example of a conversion program
This example prints the Euro character (coded hex 80) on an X terminal.
#include <monetary.h>
#include <locale.h>
#include <stdio.h>
main(int argc, char **argv)
{
char bfr[256];
ssize_t size;
float value, cours = 6.55957;
(void) setlocale (LC_ALL, ”fr_FR.IBM–1252”);
value = 10000.00;
size = strfmon(bfr, 256, ”%+15#5.2n”, value);
printf (”valeur en Francs: %s ”, bfr);
value = 10000.00 / cours;
(void) setlocale (LC_MONETARY, ”fr_FR.IBM–1252@euro”);
size = strfmon(bfr, 256, ”%+15#5.2n”, value);
if (size > 0)
printf (”soit en EUROS: %s\n”, bfr);
}
9.3.2 ISO8859–15: Example of a conversion program
This example prints the Euro character (coded hex a4) on an ASCII BQ306 terminal.
#include <monetary.h>
#include <locale.h>
#include <stdio.h>
main(int argc, char **argv)
{
char bfr[256];
ssize_t size;
float value, cours = 6.55957;
char euro = 0xa4;
(void) setlocale (LC_ALL, ”fr_FR.IBM–1252”);
value = 10000.00;
size = strfmon(bfr, 256, ”%+15#5.2n”, value);
printf (”valeur en Francs: %s ”, bfr);
value = 10000.00 / cours;
printf (”%s soit en EUROS: %5.2f %c\n”, bfr, value,
euro);
}