First public contribution.
1 // Copyright (c) 2006-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 "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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Name : lnumeric.CPP
16 // Contains the source for LC_NUMERIC category
18 // This material, including documentation and any related
19 // computer programs, is protected by copyright controlled by
20 // Nokia Corporation. All rights are reserved. Copying,
21 // including reproducing, storing, adapting or translating, any
22 // or all of this material requires the prior written consent of
23 // Nokia Corporation. This material also contains confidential
24 // information which may not be disclosed to others without the
25 // prior written consent of Nokia Corporation.
29 #include <sys/cdefs.h>
30 #include "localeinfo.h"
33 #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
34 #include "libc_wsd_defs.h"
37 extern int __nlocale_changed;
39 int *GET_WSD_VAR_NAME(__nlocale_changed, g)();
40 #define __nlocale_changed (*GET_WSD_VAR_NAME(__nlocale_changed, g)())
44 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
45 extern unsigned char __clocale_set;
47 unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)();
48 #define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)())
52 int _numeric_using_locale;
55 GET_GLOBAL_VAR_FROM_TLS(_numeric_using_locale, int)
56 #define _numeric_using_locale (*GET_WSD_VAR_NAME(_numeric_using_locale, g)())
60 static char numempty[] = { CHAR_MAX, '\0' };
62 static const char numempty[] = { CHAR_MAX, '\0'};
66 static const struct lc_numeric_T _C_numeric_locale = {
67 ".", /* decimal_point */
68 "", /* thousands_sep */
69 numempty /* grouping */
73 int __numeric_load_locale(const char* localeName)
75 //Get an instance of locale object
76 CLocale* locale = CLocale::GetInstance();
77 //Load numeric(LC_NUMERIC category) information
78 if (locale->NumericLoadLocale(localeName) == -1)
82 __nlocale_changed = 1;
83 _numeric_using_locale = 1;
88 struct lc_numeric_T* __get_current_numeric_locale(void)
90 //Retrieve numeric(LC_NUMERIC category) information
91 if(_numeric_using_locale)
93 return (CLocale::GetCurrentNumericLocale());
95 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
96 else if(__clocale_set)
98 //retrieve POSIX locale numeric(LC_NUMERIC category) information
99 return ((struct lc_numeric_T *)&_C_numeric_locale);
100 #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT
103 CLocale *l=CLocale::GetInstance();
104 l->NumericLoadLocale(NULL);
105 return (CLocale::GetCurrentNumericLocale());
113 printf( "decimal_point = %s\n"
114 "thousands_sep = %s\n"
116 _numeric_locale.decimal_point,
117 _numeric_locale.thousands_sep,
118 _numeric_locale.grouping
121 #endif /* LOCALE_DEBUG */