C++ examples for Internationalization:Locale
Format Numeric Values for a Locale
#include <iostream> #include <locale> #include <iomanip> using namespace std; int main()/* ww w. j av a2s . c o m*/ { // Use a fixed format with 2 decimal places. cout << fixed << setprecision(2); cout << "Default format: " << 12345678.12 << "\n\n"; // Set the locale to English. locale eloc("English"); cout.imbue(eloc); cout << "English format: " << 12345678.12 << "\n\n"; locale gloc("German"); cout.imbue(gloc); cout << "German format: " << 12345678.12 << "\n\n"; return 0; }