00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 #include "localeupdate.h"
00025
00026 LOCAL_D CConsoleBase* console;
00027
00028 LOCAL_C void DoStartL();
00029
00030 LOCAL_C void CallExampleL();
00031
00038 CLocaleSettings* CLocaleSettings::NewL(TDesC16& aLocaleDLLName, CConsoleBase* aConsole)
00039 {
00040 CLocaleSettings* self = new (ELeave) CLocaleSettings;
00041 CleanupStack::PushL(self);
00042 self->ConstructL(aLocaleDLLName, aConsole);
00043 CleanupStack::Pop(self);
00044 return self;
00045 }
00046
00053 void CLocaleSettings::ConstructL(TDesC16& aLocaleDLLName, CConsoleBase* aConsole)
00054 {
00055
00056 iLocaleDLLName.Copy(aLocaleDLLName);
00057 iConsole = aConsole;
00058
00059
00060 User::LeaveIfError(iExtendedLocale.LoadLocale(iLocaleDLLName));
00061
00062
00063 iLocale = iExtendedLocale.GetLocale();
00064
00065
00066
00067 iStartOfWeek = iLocale->StartOfWeek();
00068
00069
00070
00071
00072 iWorkingDaysMask = iLocale->WorkDays();
00073
00074
00075 iCollationMethod = iExtendedLocale.GetPreferredCollationMethod();
00076
00077
00078 iCountryCode = iLocale->CountryCode();
00079
00080
00081 iDateFormat = iLocale->DateFormat();
00082
00083
00084 iTimeFormat = iLocale->TimeFormat();
00085
00086
00087 iThousandsSeparator = iLocale->ThousandsSeparator();
00088 iDecimalSeparator = iLocale->DecimalSeparator();
00089
00090
00091 iUnitsFormat = iLocale->UnitsGeneral();
00092
00093
00094
00095 iUTCOffset = User::UTCOffset();
00096 }
00097
00101 CLocaleSettings::CLocaleSettings()
00102 {
00103 }
00104
00108 void CLocaleSettings::DisplayLocaleSettings()
00109 {
00110
00111 _LIT(KTextDLLName, "\r\nLocale Settings for the DLL:");
00112 console->Printf(KTextDLLName);
00113 console->Printf(iLocaleDLLName);
00114 console->Printf(KTextNewLine);
00115
00116
00117 _LIT(KTextCalenderSettings, "Calendar Settings:\r\n1. First day of the week: %d\r\n");
00118 iConsole->Printf(KTextCalenderSettings, iStartOfWeek);
00119
00120
00121 _LIT(KTextWorkingDays, "2. Working days of the week [LSB - Monday]: %07b\r\n");
00122 iConsole->Printf(KTextWorkingDays, iWorkingDaysMask);
00123
00124
00125 _LIT(KTextCollationMethod, "Collation method:");
00126 iConsole->Printf(KTextCollationMethod);
00127 if(iCollationMethod.iFlags & TCollationMethod::EIgnoreNone)
00128 {
00129 _LIT(KTextIgnoreNone, "IgnoreNone\r\n");
00130 iConsole->Printf(KTextIgnoreNone);
00131 }
00132 else if(iCollationMethod.iFlags & TCollationMethod::ESwapCase)
00133 {
00134 _LIT(KTextSwapCase, "SwapCase\r\n");
00135 iConsole->Printf(KTextSwapCase);
00136 }
00137 else if(iCollationMethod.iFlags & TCollationMethod::EAccentsBackwards)
00138 {
00139 _LIT(KTextAccents, "AccentsBackwards\r\n");
00140 iConsole->Printf(KTextAccents);
00141 }
00142 else if(iCollationMethod.iFlags & TCollationMethod::ESwapKana)
00143 {
00144 _LIT(KTextSwapKana, "SwapKana\r\n");
00145 iConsole->Printf(KTextSwapKana);
00146 }
00147 else if(iCollationMethod.iFlags & TCollationMethod::EFoldCase)
00148 {
00149 _LIT(KTextFoldCase, "FoldCase\r\n");
00150 iConsole->Printf(KTextFoldCase);
00151 }
00152 else
00153 {
00154 _LIT(KTextStandard, "Standard\r\n");
00155 iConsole->Printf(KTextStandard);
00156 }
00157
00158
00159 _LIT(KTextCountryCode, "Country code: %d\r\n");
00160 iConsole->Printf(KTextCountryCode, iCountryCode);
00161
00162
00163 TBuf<50> currency;
00164
00165 TInt currencyValue = 10241024;
00166 iLocale->FormatCurrency(currency, currencyValue);
00167
00168 _LIT(KTextCurrencyFormat, "Currency format of %d:");
00169 iConsole->Printf(KTextCurrencyFormat, currencyValue);
00170 iConsole->Printf(currency);
00171 iConsole->Printf(KTextNewLine);
00172
00173
00174 _LIT(KTextDateFormat, "Date Format: ");
00175 iConsole->Printf(KTextDateFormat);
00176 switch(iDateFormat)
00177 {
00178 case EDateAmerican:
00179 _LIT(KTextUSFormat, "US Format (mm/dd/yy)\r\n");
00180 iConsole->Printf(KTextUSFormat);
00181 break;
00182 case EDateEuropean:
00183 _LIT(KTextEuropeanFormat, "European format (dd/mm/yyyy)\r\n");
00184 iConsole->Printf(KTextEuropeanFormat);
00185 break;
00186 case EDateJapanese:
00187 _LIT(KTextJapFormat, "Japanese format (yyyy/mm/dd)\r\n");
00188 iConsole->Printf(KTextJapFormat);
00189 break;
00190 }
00191
00192
00193 _LIT(KTextTimeFormat, "Time Format: ");
00194 iConsole->Printf(KTextTimeFormat);
00195 if(iTimeFormat == ETime12)
00196 {
00197 _LIT(KText12Hour, "12 hour format\r\n");
00198 iConsole->Printf(KText12Hour);
00199 }
00200 else
00201 {
00202 _LIT(KText24Hour, "24 hour format\r\n");
00203 iConsole->Printf(KText24Hour);
00204 }
00205
00206
00207 _LIT(KTextNumericValues, "Numeric Values: \r\n");
00208 iConsole->Printf(KTextNumericValues);
00209 _LIT(KTextThousandsSeparator, "\tThousands separator: %c\r\n");
00210 iConsole->Printf(KTextThousandsSeparator, TUint(iThousandsSeparator));
00211 _LIT(KTextDecimalSeparator, "\tDecimal separator: %c\r\n");
00212 iConsole->Printf(KTextDecimalSeparator, TUint(iDecimalSeparator));
00213
00214
00215 _LIT(KTextTimeZone, "UTC Offset in seconds (Time Zone Information): %d\r\n");
00216 iConsole->Printf(KTextTimeZone, iUTCOffset.Int());
00217
00218
00219 _LIT(KTextUnitsOfMeasure, "Units of measurement: ");
00220 iConsole->Printf(KTextUnitsOfMeasure);
00221 if(iUnitsFormat == EUnitsImperial)
00222 {
00223 _LIT(KTextImperial, "Imperial\r\n");
00224 iConsole->Printf(KTextImperial);
00225 }
00226 else
00227 {
00228 _LIT(KTextMetric, "Metric\r\n");
00229 iConsole->Printf(KTextMetric);
00230 }
00231 }
00232
00236 CLocaleSettings::~CLocaleSettings()
00237 {
00238 }
00239
00240 LOCAL_C void DoStartL()
00241 {
00242
00243 _LIT(KLocaleName1, "elocl.01");
00244 TBufC<KLength> localeName1(KLocaleName1);
00245
00246 CLocaleSettings* obj = CLocaleSettings::NewL(localeName1, console);
00247 CleanupStack::PushL(obj);
00248
00249 obj->DisplayLocaleSettings();
00250
00251 CleanupStack::PopAndDestroy(obj);
00252
00253 console->Printf(KTextPressAnyKey);
00254 console->Getch();
00255
00256
00257 _LIT(KLocaleName2, "elocl.10");
00258 TBufC<KLength> localeName2(KLocaleName2);
00259
00260 obj = CLocaleSettings::NewL(localeName2, console);
00261 CleanupStack::PushL(obj);
00262
00263 obj->DisplayLocaleSettings();
00264
00265 CleanupStack::PopAndDestroy(obj);
00266
00267 console->Printf(KTextPressAnyKey);
00268 console->Getch();
00269
00270
00271 _LIT(KLocaleName3, "elocl.29");
00272 TBufC<KLength> localeName3(KLocaleName3);
00273
00274 obj = CLocaleSettings::NewL(localeName3, console);
00275 CleanupStack::PushL(obj);
00276
00277 obj->DisplayLocaleSettings();
00278
00279 CleanupStack::PopAndDestroy(obj);
00280
00281 console->Printf(KTextPressAnyKey);
00282 console->Getch();
00283
00284
00285 _LIT(KLocaleName4, "elocl.32");
00286 TBufC<KLength> localeName4(KLocaleName4);
00287
00288 obj = CLocaleSettings::NewL(localeName4, console);
00289 CleanupStack::PushL(obj);
00290
00291 obj->DisplayLocaleSettings();
00292
00293 CleanupStack::PopAndDestroy(obj);
00294 }
00295
00296 GLDEF_C TInt E32Main()
00297 {
00298 __UHEAP_MARK;
00299 CTrapCleanup* cleanup=CTrapCleanup::New();
00300 TRAPD(error, CallExampleL());
00301 delete cleanup;
00302 __ASSERT_ALWAYS(!error, User::Panic(KTxtEPOC32EX, error));
00303 __UHEAP_MARKEND;
00304 return 0;
00305 }
00306
00307 LOCAL_C void CallExampleL()
00308 {
00309 console=Console::NewL(KTxtExampleCode, TSize(KConsFullScreen, KConsFullScreen));
00310 CleanupStack::PushL(console);
00311 TRAPD(error, DoStartL());
00312 if (error)
00313 console->Printf(KFormatFailed, error);
00314 else
00315 console->Printf(KTxtOK);
00316 console->Printf(KTextPressAnyKey);
00317 console->Getch();
00318 CleanupStack::PopAndDestroy();
00319 }