/*
********************************************************************************
-* Copyright (C) 2005-2007, International Business Machines
+* Copyright (C) 2005-2016, International Business Machines
* Corporation and others. All Rights Reserved.
********************************************************************************
*
#include "unicode/utypes.h"
-#ifdef U_WINDOWS
+#if U_PLATFORM_USES_ONLY_WIN32_API
#if !UCONFIG_NO_FORMATTING
}
}
-// TODO: keep locale too?
Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErrorCode &status)
- : NumberFormat(), fCurrency(currency), fFractionDigitsSet(FALSE), fFormatInfo(NULL)
+ : NumberFormat(), fCurrency(currency), fFormatInfo(NULL), fFractionDigitsSet(FALSE)
{
if (!U_FAILURE(status)) {
fLCID = locale.getLCID();
+ // Resolve actual locale to be used later
+ UErrorCode tmpsts = U_ZERO_ERROR;
+ char tmpLocID[ULOC_FULLNAME_CAPACITY];
+ int32_t len = uloc_getLocaleForLCID(fLCID, tmpLocID, UPRV_LENGTHOF(tmpLocID) - 1, &tmpsts);
+ if (U_SUCCESS(tmpsts)) {
+ tmpLocID[len] = 0;
+ fLocale = Locale((const char*)tmpLocID);
+ }
+
fFormatInfo = (FormatInfo*)uprv_malloc(sizeof(FormatInfo));
if (fCurrency) {
NumberFormat::operator=(other);
this->fCurrency = other.fCurrency;
+ this->fLocale = other.fLocale;
this->fLCID = other.fLCID;
this->fFractionDigitsSet = other.fFractionDigitsSet;
return format(getMinimumFractionDigits(), appendTo, L"%I64d", number);
}
-// TODO: cache Locale and NumberFormat? Could keep locale passed to constructor...
void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, ParsePosition& parsePosition) const
{
UErrorCode status = U_ZERO_ERROR;
- Locale loc(uprv_convertToPosix(fLCID, &status));
- NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(loc, status) : NumberFormat::createInstance(loc, status);
+ NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(fLocale, status) : NumberFormat::createInstance(fLocale, status);
nf->parse(text, result, parsePosition);
delete nf;
NumberFormat::setMinimumFractionDigits(newValue);
}
-UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appendTo, wchar_t *fmt, ...) const
+UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appendTo, const wchar_t *fmt, ...) const
{
wchar_t nStackBuffer[STACK_BUFFER_SIZE];
wchar_t *nBuffer = nStackBuffer;
#endif /* #if !UCONFIG_NO_FORMATTING */
-#endif // #ifdef U_WINDOWS
+#endif // U_PLATFORM_USES_ONLY_WIN32_API