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