Tools.h++ Manual

104011 Tandem Computers Incorporated 4-11
4
Let us consider some examples of currency conversions:
In a U.S. locale, this displays:
1000.00000 10.00 $10.00 USD 10.00
4.2 Wrap up
We have covered lots of territory—alphabets, languages, dates, times, time
zones, numbers, money—and yet have only scratched the surface of what can
be done by combining these facilities. Internationalization is a brave new
world for software engineering, but with the proper tools it can be more
exciting than distressing.
const RWLocale& here = RWLocale::global();
double sawbuck = 1000.;
RWCString tenNone = here.moneyAsString(sawbuck, RWLocale::NONE);
RWCString tenLocal = here.moneyAsString(sawbuck,
RWLocale::LOCAL);
RWCString tenIntl = here.moneyAsString(sawbuck, RWLocale::INTL);
if (here.stringToMoney(tenNone, &sawbuck) &&
here.stringToMoney(tenLocal, &sawbuck) &&
here.stringToMoney(tenIntl, &sawbuck)) // verify conversion
cout << sawbuck << " " << tenNone << " "
<< tenLocal << " " << tenIntl << " " << endl;