sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Name : lnumeric.CPP sl@0: // Part of : LIBC sl@0: // Contains the source for LC_NUMERIC category sl@0: // Version : sl@0: // This material, including documentation and any related sl@0: // computer programs, is protected by copyright controlled by sl@0: // Nokia Corporation. All rights are reserved. Copying, sl@0: // including reproducing, storing, adapting or translating, any sl@0: // or all of this material requires the prior written consent of sl@0: // Nokia Corporation. This material also contains confidential sl@0: // information which may not be disclosed to others without the sl@0: // prior written consent of Nokia Corporation. sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "localeinfo.h" sl@0: #include "lnumeric.h" sl@0: sl@0: #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__))) sl@0: #include "libc_wsd_defs.h" sl@0: #endif sl@0: __BEGIN_DECLS sl@0: extern int __nlocale_changed; sl@0: #ifdef EMULATOR sl@0: int *GET_WSD_VAR_NAME(__nlocale_changed, g)(); sl@0: #define __nlocale_changed (*GET_WSD_VAR_NAME(__nlocale_changed, g)()) sl@0: #endif //EMULATOR sl@0: __END_DECLS sl@0: sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: extern unsigned char __clocale_set; sl@0: #ifdef EMULATOR sl@0: unsigned char *GET_WSD_VAR_NAME(__clocale_set, g)(); sl@0: #define __clocale_set (*GET_WSD_VAR_NAME(__clocale_set, g)()) sl@0: #endif //EMULATOR sl@0: #endif sl@0: #ifndef EMULATOR sl@0: int _numeric_using_locale; sl@0: #else //EMULATOR sl@0: sl@0: GET_GLOBAL_VAR_FROM_TLS(_numeric_using_locale, int) sl@0: #define _numeric_using_locale (*GET_WSD_VAR_NAME(_numeric_using_locale, g)()) sl@0: #endif //EMULATOR sl@0: sl@0: #ifndef EMULATOR sl@0: static char numempty[] = { CHAR_MAX, '\0' }; sl@0: #else //EMULATOR sl@0: static const char numempty[] = { CHAR_MAX, '\0'}; sl@0: #endif //EMULATOR sl@0: sl@0: sl@0: static const struct lc_numeric_T _C_numeric_locale = { sl@0: ".", /* decimal_point */ sl@0: "", /* thousands_sep */ sl@0: numempty /* grouping */ sl@0: }; sl@0: sl@0: sl@0: int __numeric_load_locale(const char* localeName) sl@0: { sl@0: //Get an instance of locale object sl@0: CLocale* locale = CLocale::GetInstance(); sl@0: //Load numeric(LC_NUMERIC category) information sl@0: if (locale->NumericLoadLocale(localeName) == -1) sl@0: { sl@0: return -1; sl@0: } sl@0: __nlocale_changed = 1; sl@0: _numeric_using_locale = 1; sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: struct lc_numeric_T* __get_current_numeric_locale(void) sl@0: { sl@0: //Retrieve numeric(LC_NUMERIC category) information sl@0: if(_numeric_using_locale) sl@0: { sl@0: return (CLocale::GetCurrentNumericLocale()); sl@0: } sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else if(__clocale_set) sl@0: #endif sl@0: //retrieve POSIX locale numeric(LC_NUMERIC category) information sl@0: return ((struct lc_numeric_T *)&_C_numeric_locale); sl@0: #ifdef SYMBIAN_OE_ENHANCED_LOCALE_SUPPORT sl@0: else sl@0: { sl@0: CLocale *l=CLocale::GetInstance(); sl@0: l->NumericLoadLocale(NULL); sl@0: return (CLocale::GetCurrentNumericLocale()); sl@0: } sl@0: #endif sl@0: } sl@0: sl@0: #ifdef LOCALE_DEBUG sl@0: void sl@0: numericdebug(void) { sl@0: printf( "decimal_point = %s\n" sl@0: "thousands_sep = %s\n" sl@0: "grouping = %s\n", sl@0: _numeric_locale.decimal_point, sl@0: _numeric_locale.thousands_sep, sl@0: _numeric_locale.grouping sl@0: ); sl@0: } sl@0: #endif /* LOCALE_DEBUG */