os/kernelhwsrv/kernel/eka/include/kernel/localise.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32\include\kernel\localise.h
    15 // 
    16 // WARNING: This file contains some APIs which are internal and are subject
    17 //          to change without notice. Such APIs should therefore not be used
    18 //          outside the Kernel and Hardware Services package.
    19 //
    20 
    21 /**
    22  @file
    23  @publishedPartner
    24  @released
    25 */
    26 
    27 #ifndef __K32LOCL_H__
    28 #define __K32LOCL_H__
    29 #include <u32std.h>
    30 
    31 class TDesC16;
    32 class TDes16;
    33 
    34 #ifdef _UNICODE
    35 #define TLocaleText TText16
    36 #else
    37 #define TLocaleText TText8
    38 #endif
    39 
    40 /**
    41 It is a container for functions to convert from a 8-bit string to a 16-bit(UNICODE) string and vice-versa, and to check
    42 whether a character is a legal short character or not.
    43 It declares pointers to functions that accomplishes the above tasks.  
    44 
    45 The functions are to be implemented by the locale-DLLs.
    46 */
    47 struct TFatUtilityFunctions // functions to be implemented by locale-DLLs
    48 	{
    49 	/**
    50 	Specifies the action to be taken if an overflow occurs. It can either Leave or Truncate the overflow part.
    51 	*/
    52 	enum TOverflowAction
    53 		{
    54 		/**
    55 		Will leave if an overflow occurs.
    56 		*/
    57 		EOverflowActionLeave,
    58 		/** 
    59 		Will truncate the data if an overflow occurs.
    60 		*/
    61 		EOverflowActionTruncate
    62 		};
    63 	/**
    64 	Function to convert a string from unicode(16-bit)format to a (8-bit) format.
    65 	
    66 	@param  aForeign  										8-bit descriptor that will contain the converted string.
    67 	@param  aUnicode  										16-bit descriptor which contains the string to be converted.
    68 	@param  aReplacementForUnconvertibleUnicodeCharacters	Any default 8-bit character that will replace any non convertible 16-bit unicode character.
    69 	@param  aOverFlowAction									Enum value specifying action to be taken in case of overflow.
    70 	
    71 	@see TOverflowAction.	
    72 	*/
    73 	typedef void (*TConvertFromUnicodeL)(TDes8& aForeign, const TDesC16& aUnicode, const TDesC8& aReplacementForUnconvertibleUnicodeCharacters, TOverflowAction aOverflowAction);
    74 	
    75 	/**
    76 	Function to convert a string from (8-bit) format to unicode(16-bit)format.
    77 	
    78 	@param  aUnicode  										16-bit descriptor which will contain the converted string.
    79 	@param  aForeign  										8-bit descriptor which contains the string to be converted.
    80 	@param  aOverFlowAction									Enum value specifying action to be taken in case of overflow. 
    81 	
    82 	@see TOverflowAction.
    83 	*/
    84 	typedef void (*TConvertToUnicodeL)(TDes16& aUnicode, const TDesC8& aForeign, TOverflowAction aOverflowAction);
    85 	
    86 	/**
    87 	Function to check whether a character is a legal short name character or not.
    88 	
    89 	@param aCharacter The character to apply the check on.
    90 	
    91 	@return TBool True  If it is a legal short name character
    92 				  False otherwise.
    93 	*/
    94 	typedef TBool (*TIsLegalShortNameCharacter)(TUint aCharacter);
    95 	
    96 	/** 
    97 	A pointer to a function TConvertFromUnicodeL. This is one of the pointers returned when Locl::FatUtilityFunctions is called.
    98 	
    99 	@see TConvertFromUnicodeL.
   100 	*/
   101 	TConvertFromUnicodeL iConvertFromUnicodeL;
   102 	
   103 	/** 
   104 	A pointer to a function TConvertToUnicodeL. This is one of the pointers returned when Locl::FatUtilityFunctions is called.
   105 	
   106 	@see TConvertToUnicodeL.
   107 	*/
   108 	TConvertToUnicodeL iConvertToUnicodeL;
   109 	
   110 	/** 
   111 	A pointer to a function TIsLegalShortNameCharacter. This is one of the pointers returned when Locl::FatUtilityFunctions is called.
   112 	
   113 	@see TIsLegalShortNameCharacter.
   114 	*/
   115 	TIsLegalShortNameCharacter iIsLegalShortNameCharacter;
   116 	};
   117 
   118 /**
   119 A data structure containing the system's locale settings.
   120 The data must be identical to that in TLocale.
   121 */
   122 struct SLocaleData
   123 	{
   124 	/** 
   125 	Integer value specifying country code.
   126 	The country code is the code used as the international dialling prefix. 
   127 	This code is also used to identify a country by the dialling software.
   128 	*/
   129 	TInt iCountryCode;
   130 	
   131 	/**
   132 	The locale's universal time offset. Offset in seconds from universal time.
   133 	Time zones east of universal time have positive offsets. 
   134 	Time zones west of universal time have negative offsets.
   135 	*/
   136 	TInt iUniversalTimeOffset;
   137 	
   138 	/**
   139 	The date format of the Locale. It can be either of the three formats American,European or Japanese.
   140     */
   141 	TDateFormat iDateFormat;
   142 	
   143 	/**
   144 	The time formats as either 12 hour or 24 hour.
   145 	*/ 
   146     TTimeFormat iTimeFormat;
   147     
   148     /**
   149     The currency symbol is located before or after the currency amount.
   150     */
   151 	TLocalePos iCurrencySymbolPosition;
   152 	
   153 	/**
   154 	Whether or not a space is inserted between the currency symbol and the currency value.
   155 	True if a space exists, False otherwise.
   156     */
   157 	TBool iCurrencySpaceBetween;
   158 	
   159 	/** The number of decimal places to which currency values are set.*/
   160 	TInt iCurrencyDecimalPlaces;
   161 	
   162 	/**
   163 	Indicates how negative currency values are formatted. 
   164 	*/
   165 	TNegativeCurrencyFormat iNegativeCurrencyFormat;
   166 	
   167 	/**
   168 	Sets whether triads are allowed in currency values.
   169 	True if Triads are allowed, False otherwise.
   170 	*/
   171 	TBool iCurrencyTriadsAllowed;
   172 	
   173 	/**
   174 	The character to be used to separate groups of three digits to the left of the decimal separator.
   175 	A thousands separator character is only displayed in currency values if currency triads are allowed.
   176 	*/
   177 	TChar iThousandsSeparator;
   178 	
   179 	/**
   180 	The character used to separate a whole number from its fractional part.
   181 	*/
   182 	TChar iDecimalSeparator;
   183 	
   184 	/**
   185 	An array containing the four characters used to separate the day, month and year components of the date.
   186 	If the four separators are represented by S0, S1, S2 and S3 
   187 	and the three date components are represented by XX, YY and ZZ,
   188 	then the separators are located: S0 XX S1 YY S2 ZZ S3.
   189     */
   190 	TChar iDateSeparator[KMaxDateSeparators];
   191 	
   192 	/**
   193     An array containing the four characters used to separate the hour, second and minute components of the time.
   194 	If the four separators are represented by S0, S1, S2 and S3 
   195 	and the three time components are represented by XX, YY and ZZ, 
   196 	then the separators are located: S0 XX S1 YY S2 ZZ S3.
   197 	*/
   198 	TChar iTimeSeparator[KMaxTimeSeparators];
   199 	
   200 	/**
   201     Defines whether the am/pm text is located before or after the time.
   202     */
   203 	TLocalePos iAmPmSymbolPosition;
   204 	
   205 	/**
   206 	Whether or not a space is inserted between the time and the preceding or trailing am/pm text.
   207 	True if a space exists, False otherwise.
   208 	*/
   209 	TBool iAmPmSpaceBetween;
   210 	
   211 	/**
   212 	The zones in which daylight saving is in effect.
   213 
   214 	If daylight saving is in effect, one hour is added to the time.
   215 
   216 	A bit mask in which the three least significant bits are defined, 
   217 	indicating which of the three daylight saving zones are adjusted for daylight saving. 
   218 	These bits represent: Northern (non-European countries in the northern hemisphere), 
   219 						  Southern (southern hemisphere), 
   220 						  and European. see TDaylightSavingZone.
   221 						  
   222 	@see TDaylightSavingZone.
   223 	*/
   224 	TUint iDaylightSaving;
   225 	
   226 	/**
   227 	The daylight saving zone in which the home city is located.
   228 	*/
   229 	TDaylightSavingZone iHomeDaylightSavingZone;
   230 	
   231 	/**
   232 	A bit mask representing the days of the week which are considered as working days.
   233 	
   234 	A bit mask of seven bits indicating (by being set) which days are workdays. 
   235 	The least significant bit corresponds to Monday, the next bit to Tuesday and so on. 
   236 	*/
   237 	TUint iWorkDays;
   238 	
   239 	/**
   240 	The day which is considered to be the first day of the week.
   241 		
   242 	The enumerator symbol names correspond with the days of the week, i.e. EMonday refers to Monday etc. 
   243 	*/
   244 	TDay iStartOfWeek;
   245 	
   246 	/**
   247 	The clock display format as either analog or digital. 
   248 	*/
   249 	TClockFormat iClockFormat;
   250 	
   251 	/**
   252 	
   253 	The general units of measurement.
   254 
   255 	This should be used when both short and long distances use the same units of measurement.
   256     */
   257 	TUnitsFormat iUnitsGeneral;
   258 	
   259 	/**
   260 	The units of measurement for short distances.
   261 
   262 	Short distances are those which would normally be represented by either metres and centimetres or feet and inches.
   263 	*/
   264 	TUnitsFormat iUnitsDistanceShort;
   265 	
   266 	/**
   267 	The units of measurement for long distances.
   268 
   269 	Long distances are those which would normally be represented by either miles or kilometres.
   270 	*/
   271 	TUnitsFormat iUnitsDistanceLong;
   272 	
   273 	/**
   274 	Flags for negative currency values formatting.
   275 
   276 	EFlagNegativeLoseSpace 			  		If this flag is set and the currency value being formatted is negative,
   277 						 					if there is a space between the currency symbol and the value, that space is lost.
   278  
   279 	EFlagNegativeCurrencySymbolOpposite 	If this flag is set and the currency value being formatted is negative, 
   280 											the position of the currency symbol is placed in the opposite direction 
   281 											from the position set for the positive currency value.
   282  	*/
   283 	TUint iExtraNegativeCurrencyFormatFlags;
   284 	
   285 	
   286 	/**
   287 	An array which contains customisable part of the language downgrade path.
   288 	*/
   289 	TUint16 iLanguageDowngrade[3];
   290 	
   291 	TUint16 iSpare16;
   292 	
   293 	/**
   294 	The number mode stored in the locale.
   295 	*/
   296 	TDigitType iDigitType;
   297 	
   298 	/**
   299 	The device time state.
   300 	*/
   301  	TDeviceTimeState iDeviceTimeState;
   302  	
   303  	TInt iSpare[0x1E];
   304 	};
   305 
   306 /**
   307 An interface defined to provide support for localisation for components 
   308 that are too low-level to participate in the normal EPOC localisation 
   309 mechanisms.
   310 */
   311 class Locl
   312 	{
   313 public:
   314 	/**
   315 	Returns the Language type.
   316 	
   317 	@return The value corresponding to a particular language as specified in TLanguage.
   318 	*/
   319 	IMPORT_C static TLanguage Language();
   320 	
   321 	/**
   322 	Returns whether it is a Unicode Build or not.
   323 	
   324 	@return True 	If it is a Unicode Build.
   325 	@return False	Otherwise.
   326 	*/
   327 	IMPORT_C static TBool UniCode();
   328 	
   329 	/**
   330 	Create the Localisation Table.
   331 	
   332 	@param aLocale a pointer to a structure of type SLocaleData. 
   333 	*/
   334 	IMPORT_C static void LocaleData(SLocaleData *aLocale);
   335 	
   336 	/**
   337 	Returns the address of the Currency Symbol.
   338 	
   339 	@return const TText16 * Address of the Currency Symbol.
   340 	*/
   341 	IMPORT_C static const TLocaleText* CurrencySymbol();
   342 	
   343 	/**
   344 	Returns the address of the short date format.
   345 	
   346 	@return  const TText16 * Address of the Short date format.
   347 	*/
   348 	IMPORT_C static const TLocaleText* ShortDateFormatSpec();
   349 	
   350 	/**
   351 	Returns the address of the long date format.
   352 	
   353 	@return  const TText16 * Address of the Long date format. 
   354 	*/
   355 	IMPORT_C static const TLocaleText* LongDateFormatSpec();
   356 	
   357 	/**
   358 	Returns the address of the time format.
   359 	
   360 	@return  const TText16 * Address of the time format. 
   361 	*/
   362 	IMPORT_C static const TLocaleText* TimeFormatSpec();
   363 	
   364 	/**
   365 	Returns the addresses of the FAT utility functions.
   366 	
   367 	@return  const TFatUtilityFunctions * Addresses of the FAT utility functions.
   368 	*/
   369 	IMPORT_C static const TFatUtilityFunctions* FatUtilityFunctions();
   370 	
   371 	/**
   372 	Returns the address of the data suffix table.
   373 	
   374 	@return  const TText16 * Address of the Date Suffix Table.
   375 	*/
   376 	IMPORT_C static const TLocaleText* const *DateSuffixTable();
   377 	
   378 	/**
   379 	Returns the address of the day table.
   380 	
   381 	@return  const TText16 * Address of the Day table.
   382 	*/
   383 	IMPORT_C static const TLocaleText* const *DayTable();
   384 	
   385 	/**
   386 	Returns the address of the abbreviated day table.
   387 	
   388 	@return  const TText16 * Address of the abbreviated day table.
   389 	*/
   390 	IMPORT_C static const TLocaleText* const *DayAbbTable();
   391 	
   392 	/**
   393 	Returns the address of the month table.
   394 	
   395 	@return  const TText16 * Address of the month table.
   396 	*/
   397 	IMPORT_C static const TLocaleText* const *MonthTable();
   398 	
   399 	/**
   400 	Returns the address of the abbreviated month table.
   401 	
   402 	@return  const TText16 * Address of the abbreviated month table.
   403 	*/
   404 	IMPORT_C static const TLocaleText* const *MonthAbbTable();
   405 	
   406 	/**
   407 	Returns the address of the ampm table.
   408 	
   409 	@return  const TText16 * Address of the ampm table.
   410 	*/
   411 	IMPORT_C static const TLocaleText* const *AmPmTable();
   412 	
   413 	/**
   414 	Returns the address of the message table.
   415 	
   416 	@return  const TText16 * Address of the message table.
   417 	*/
   418 	IMPORT_C static const TLocaleText* const *MsgTable();
   419 	
   420 	/**
   421 	Returns the address of the locale character set object: contains collation rules etc.
   422 	
   423 	@return	 const LCharSet * Address of the locale character set if its a UNICODE build; NULL otherwise.
   424 	*/
   425 	IMPORT_C static const LCharSet *CharSet();
   426 	
   427 	/**
   428 	Returns the address of the character type conversion table.
   429 	
   430 	@return  const TUint8 * Address of the character type conversion table if its a NON-UNICODE build;NULL otherwise
   431 	*/
   432 	IMPORT_C static const TUint8 *TypeTable();
   433 	
   434 	/**
   435 	Returns the address of the uppercase table.
   436 	
   437 	@return  const TText16 * Address of the uppercase table if its a NON-UNICODE build;NULL otherwise
   438 	
   439 	*/
   440 	IMPORT_C static const TLocaleText* UpperTable();
   441 	
   442 	/**
   443 	Returns the address of the lowercase table.
   444 	
   445 	@return  const TText16 * Address of the lowercase table if its a NON-UNICODE build;NULL otherwise
   446 
   447 	
   448 	*/
   449 	IMPORT_C static const TLocaleText* LowerTable();
   450 	
   451 	/**
   452 	Returns the address of the fold table.
   453 	
   454 	@return  const TText16 * Address of the fold table if its a NON-UNICODE build;NULL otherwise
   455 	
   456 	*/
   457 	IMPORT_C static const TLocaleText* FoldTable();
   458 	
   459 	/**
   460 	Returns the address of the collate table.
   461 	
   462 	@return  const TText16 * Address of the fold table if its a NON-UNICODE build;NULL otherwise
   463 	
   464 	*/
   465 	IMPORT_C static const TLocaleText* CollTable();
   466 	};
   467 
   468 /**
   469 @internalTechnology
   470 @deprecated
   471 */
   472 class LCountry
   473 	{
   474 public:
   475 	static const TLanguage Language;
   476 	static const TInt CountryCode;
   477 	static const TInt UniversalTimeOffset;
   478 	static const TDateFormat DateFormat;
   479 	static const TTimeFormat TimeFormat;
   480 	static const TLocaleText * const CurrencySymbol;
   481 	static const TLocalePos CurrencySymbolPosition;
   482 	static const TBool CurrencySpaceBetween;
   483 	static const TInt CurrencyDecimalPlaces;
   484 	static const TBool CurrencyNegativeInBrackets;
   485 	static const TBool CurrencyTriadsAllowed;
   486 	static const TLocaleText* const ShortDateFormatSpec;
   487 	static const TLocaleText* const LongDateFormatSpec;
   488 	static const TLocaleText* const TimeFormatSpec;
   489 	static const TFatUtilityFunctions* const FatUtilityFunctions;
   490 	static const TLocaleText * const ThousandsSeparator;
   491 	static const TLocaleText * const DecimalSeparator;
   492 	static const TLocaleText * const DateSeparator[KMaxDateSeparators];
   493 	static const TLocaleText * const TimeSeparator[KMaxTimeSeparators];
   494 	static const TLocalePos AmPmSymbolPosition;
   495 	static const TBool AmPmSpaceBetween;
   496 //	static const TUint DaylightSaving;
   497 	static const TDaylightSavingZone HomeDaylightSavingZone;
   498 	static const TUint WorkDays;
   499 	static const TDay StartOfWeek;
   500 	static const TClockFormat ClockFormat;
   501 	static const TUnitsFormat UnitsGeneral;
   502 	static const TUnitsFormat UnitsDistanceLong;
   503 	static const TUnitsFormat UnitsDistanceShort;
   504 	};
   505 
   506 
   507 /**
   508 Settings for the locale language. They are some text tables of 
   509 day names, month names etc.
   510 */
   511 class LLanguage
   512 	{
   513 public:
   514 	/** Text table containing the suffix strings of all days in a month. */
   515 	static const TLocaleText * const DateSuffixTable[KMaxSuffixes];
   516 	/** Text table containing the names of days in a week. */
   517 	static const TLocaleText * const DayTable[KMaxDays];
   518 	/** Text table containing the abbreviated names of days in a week. */
   519 	static const TLocaleText * const DayAbbTable[KMaxDays];
   520 	/** Text table containing the month names. */
   521 	static const TLocaleText * const MonthTable[KMaxMonths];
   522 	/** Text table containing the abbreviated month names. */
   523 	static const TLocaleText * const MonthAbbTable[KMaxMonths];
   524 	/** Text table containing the am/pm strings. */
   525 	static const TLocaleText * const AmPmTable[KMaxAmPms];
   526 	};
   527 
   528 class LMessages
   529 	{
   530 public:
   531 	/** Text table containing the default messages for File Server, Sound Driver, and Media Drivers. */
   532 	static const TLocaleText * const MsgTable[ELocaleMessages_LastMsg];
   533 	};
   534 
   535 /*
   536  * The LAlphabet class has been abolished in the Unicode build.
   537  * Locale-specific character set information is kept in a unique LCharSet
   538  * structure (defined in U32STD.H; used by the Exec, Locl, and K classes).
   539  * The reason for having an actual object (rather than a class with no
   540  * instances but with static members) is so that its address can be
   541  * returned by the new Exec function GetLocaleCharSet().
   542  */
   543 extern const LCharSet TheCharSet;	// the one and only LCharSet object
   544 
   545 #undef TLocaleText
   546 
   547 #endif