Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(655)

Side by Side Diff: source/i18n/winnmfmt.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/winnmfmt.h ('k') | source/io/io.vcxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ******************************************************************************** 2 ********************************************************************************
3 * Copyright (C) 2005-2014, International Business Machines 3 * Copyright (C) 2005-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ******************************************************************************** 5 ********************************************************************************
6 * 6 *
7 * File WINNMFMT.CPP 7 * File WINNMFMT.CPP
8 * 8 *
9 ******************************************************************************** 9 ********************************************************************************
10 */ 10 */
11 11
12 #include "unicode/utypes.h" 12 #include "unicode/utypes.h"
13 13
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 static void freeCurrencyFormat(CURRENCYFMTW *fmt) 129 static void freeCurrencyFormat(CURRENCYFMTW *fmt)
130 { 130 {
131 if (fmt != NULL) { 131 if (fmt != NULL) {
132 DELETE_ARRAY(fmt->lpCurrencySymbol); 132 DELETE_ARRAY(fmt->lpCurrencySymbol);
133 DELETE_ARRAY(fmt->lpThousandSep); 133 DELETE_ARRAY(fmt->lpThousandSep);
134 DELETE_ARRAY(fmt->lpDecimalSep); 134 DELETE_ARRAY(fmt->lpDecimalSep);
135 } 135 }
136 } 136 }
137 137
138 Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro rCode &status) 138 Win32NumberFormat::Win32NumberFormat(const Locale &locale, UBool currency, UErro rCode &status)
139 : NumberFormat(), fCurrency(currency), fFractionDigitsSet(FALSE), fFormatInfo( NULL) 139 : NumberFormat(), fCurrency(currency), fFormatInfo(NULL), fFractionDigitsSet(F ALSE)
140 { 140 {
141 if (!U_FAILURE(status)) { 141 if (!U_FAILURE(status)) {
142 fLCID = locale.getLCID(); 142 fLCID = locale.getLCID();
143 143
144 // Resolve actual locale to be used later 144 // Resolve actual locale to be used later
145 UErrorCode tmpsts = U_ZERO_ERROR; 145 UErrorCode tmpsts = U_ZERO_ERROR;
146 char tmpLocID[ULOC_FULLNAME_CAPACITY]; 146 char tmpLocID[ULOC_FULLNAME_CAPACITY];
147 int32_t len = uloc_getLocaleForLCID(fLCID, tmpLocID, sizeof(tmpLocID)/si zeof(tmpLocID[0]) - 1, &tmpsts); 147 int32_t len = uloc_getLocaleForLCID(fLCID, tmpLocID, sizeof(tmpLocID)/si zeof(tmpLocID[0]) - 1, &tmpsts);
148 if (U_SUCCESS(tmpsts)) { 148 if (U_SUCCESS(tmpsts)) {
149 tmpLocID[len] = 0; 149 tmpLocID[len] = 0;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return *this; 202 return *this;
203 } 203 }
204 204
205 Format *Win32NumberFormat::clone(void) const 205 Format *Win32NumberFormat::clone(void) const
206 { 206 {
207 return new Win32NumberFormat(*this); 207 return new Win32NumberFormat(*this);
208 } 208 }
209 209
210 UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const 210 UnicodeString& Win32NumberFormat::format(double number, UnicodeString& appendTo, FieldPosition& pos) const
211 { 211 {
212 return variadicFormat(getMaximumFractionDigits(), appendTo, L"%.16f", number ); 212 return format(getMaximumFractionDigits(), appendTo, L"%.16f", number);
213 } 213 }
214 214
215 UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo , FieldPosition& pos) const 215 UnicodeString& Win32NumberFormat::format(int32_t number, UnicodeString& appendTo , FieldPosition& pos) const
216 { 216 {
217 return variadicFormat(getMinimumFractionDigits(), appendTo, L"%I32d", number ); 217 return format(getMinimumFractionDigits(), appendTo, L"%I32d", number);
218 } 218 }
219 219
220 UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo , FieldPosition& pos) const 220 UnicodeString& Win32NumberFormat::format(int64_t number, UnicodeString& appendTo , FieldPosition& pos) const
221 { 221 {
222 return variadicFormat(getMinimumFractionDigits(), appendTo, L"%I64d", number ); 222 return format(getMinimumFractionDigits(), appendTo, L"%I64d", number);
223 } 223 }
224 224
225 void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, Pa rsePosition& parsePosition) const 225 void Win32NumberFormat::parse(const UnicodeString& text, Formattable& result, Pa rsePosition& parsePosition) const
226 { 226 {
227 UErrorCode status = U_ZERO_ERROR; 227 UErrorCode status = U_ZERO_ERROR;
228 NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(fLocale, status) : NumberFormat::createInstance(fLocale, status); 228 NumberFormat *nf = fCurrency? NumberFormat::createCurrencyInstance(fLocale, status) : NumberFormat::createInstance(fLocale, status);
229 229
230 nf->parse(text, result, parsePosition); 230 nf->parse(text, result, parsePosition);
231 delete nf; 231 delete nf;
232 } 232 }
233 void Win32NumberFormat::setMaximumFractionDigits(int32_t newValue) 233 void Win32NumberFormat::setMaximumFractionDigits(int32_t newValue)
234 { 234 {
235 fFractionDigitsSet = TRUE; 235 fFractionDigitsSet = TRUE;
236 NumberFormat::setMaximumFractionDigits(newValue); 236 NumberFormat::setMaximumFractionDigits(newValue);
237 } 237 }
238 238
239 void Win32NumberFormat::setMinimumFractionDigits(int32_t newValue) 239 void Win32NumberFormat::setMinimumFractionDigits(int32_t newValue)
240 { 240 {
241 fFractionDigitsSet = TRUE; 241 fFractionDigitsSet = TRUE;
242 NumberFormat::setMinimumFractionDigits(newValue); 242 NumberFormat::setMinimumFractionDigits(newValue);
243 } 243 }
244 244
245 UnicodeString &Win32NumberFormat::variadicFormat(int32_t numDigits, UnicodeStrin g &appendTo, const wchar_t *fmt, ...) const 245 UnicodeString &Win32NumberFormat::format(int32_t numDigits, UnicodeString &appen dTo, const wchar_t *fmt, ...) const
246 { 246 {
247 wchar_t nStackBuffer[STACK_BUFFER_SIZE]; 247 wchar_t nStackBuffer[STACK_BUFFER_SIZE];
248 wchar_t *nBuffer = nStackBuffer; 248 wchar_t *nBuffer = nStackBuffer;
249 va_list args; 249 va_list args;
250 int result; 250 int result;
251 251
252 nBuffer[0] = 0x0000; 252 nBuffer[0] = 0x0000;
253 253
254 /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL and minus), 254 /* Due to the arguments causing a result to be <= 23 characters (+2 for NULL and minus),
255 we don't need to reallocate the buffer. */ 255 we don't need to reallocate the buffer. */
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 }*/ 352 }*/
353 353
354 return appendTo; 354 return appendTo;
355 } 355 }
356 356
357 U_NAMESPACE_END 357 U_NAMESPACE_END
358 358
359 #endif /* #if !UCONFIG_NO_FORMATTING */ 359 #endif /* #if !UCONFIG_NO_FORMATTING */
360 360
361 #endif // U_PLATFORM_USES_ONLY_WIN32_API 361 #endif // U_PLATFORM_USES_ONLY_WIN32_API
OLDNEW
« no previous file with comments | « source/i18n/winnmfmt.h ('k') | source/io/io.vcxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698