Euro Currency Support in the Solaris Operating Environment

2.1.2 Dual-Currency Support in the Euro Locales

In the Solaris operating environment, accessing locale data in ISO 8859-15 is no different than any other locale. For more information on locale-specific data, refer to the latest Solaris International Language Environments Guide. However, using these locales in a dual-currency environment requires additional explanation.

One business requirement during the transition period (January 1, 1999 to December 31, 2002) is to display prices in both the national currency and the euro. The Solaris operating environment supports both using the "@euro" extension as shown in the program example below.

Example: Dual-Currency Handling in Solaris

#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <locale.h>
#include <monetary.h> 
char buf[20]; 
main(argc,argv)
int argc; 
char *argv[];
{
	double num = atoi(argv[1]);
	setlocale(LC_MONETARY, "fr_FR.ISO8859-15");
	strfmon(buf, sizeof(buf), "%n", num);
	printf("National currency format is  %s\n",buf);
	strfmon(buf, sizeof(buf), "%i", num);
	printf("International currency format is %s\n",buf);
	setlocale(LC_MONETARY, "fr_FR.ISO8859-15@euro");
	num=num*2; strfmon*buf, sizeof(buf), "%n", num);
	printf("National currency format is %s\n",buf);
	strfmon(buf, sizeof(buf), "%i", num);
	printf("International currency format is %s\n",buf);
} 

Note -

For illustration purposes, the following example uses a fictional exchange rate conversion (1 French Franc = 2 euro). Exchange rate support is not provided in the Solaris operating environment and should be handled by the application.


The output is: show below in Figure 2-1.

Figure 2-1 Euro sample output

Graphic


Note -

To change locales in a multithreaded application, setlocale() should be called prior to using any locale-sensitive routine. Using setlocale() to query the current locale is safe, and can be used anywhere in a multithreaded application.