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

Side by Side Diff: Source/core/platform/text/LocaleWin.cpp

Issue 26113002: Move core/platform/text/Locale* to platform/text (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/platform/text/LocaleWin.h ('k') | Source/core/platform/text/PlatformLocale.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "core/platform/text/LocaleWin.h"
33
34 #include "platform/DateComponents.h"
35 #include "platform/Language.h"
36 #include "platform/LayoutTestSupport.h"
37 #include "platform/LocalizedStrings.h"
38 #include "platform/text/DateTimeFormat.h"
39 #include "wtf/CurrentTime.h"
40 #include "wtf/DateMath.h"
41 #include "wtf/HashMap.h"
42 #include "wtf/OwnPtr.h"
43 #include "wtf/PassOwnPtr.h"
44 #include "wtf/text/StringBuffer.h"
45 #include "wtf/text/StringBuilder.h"
46 #include "wtf/text/StringHash.h"
47 #include <limits>
48 #include <windows.h>
49
50 using namespace std;
51
52 namespace WebCore {
53
54 typedef LCID (WINAPI* LocaleNameToLCIDPtr)(LPCWSTR, DWORD);
55 typedef HashMap<String, LCID> NameToLCIDMap;
56
57 static String extractLanguageCode(const String& locale)
58 {
59 size_t dashPosition = locale.find('-');
60 if (dashPosition == kNotFound)
61 return locale;
62 return locale.left(dashPosition);
63 }
64
65 static String removeLastComponent(const String& name)
66 {
67 size_t lastSeparator = name.reverseFind('-');
68 if (lastSeparator == kNotFound)
69 return emptyString();
70 return name.left(lastSeparator);
71 }
72
73 static void ensureNameToLCIDMap(NameToLCIDMap& map)
74 {
75 if (!map.isEmpty())
76 return;
77 // http://www.microsoft.com/resources/msdn/goglobal/default.mspx
78 // We add only locales used in layout tests for now.
79 map.add("ar", 0x0001);
80 map.add("ar-eg", 0x0C01);
81 map.add("de", 0x0007);
82 map.add("de-de", 0x0407);
83 map.add("el", 0x0008);
84 map.add("el-gr", 0x0408);
85 map.add("en", 0x0009);
86 map.add("en-gb", 0x0809);
87 map.add("en-us", 0x0409);
88 map.add("fr", 0x000C);
89 map.add("fr-fr", 0x040C);
90 map.add("he", 0x000D);
91 map.add("he-il", 0x040D);
92 map.add("hi", 0x0039);
93 map.add("hi-in", 0x0439);
94 map.add("ja", 0x0011);
95 map.add("ja-jp", 0x0411);
96 map.add("ko", 0x0012);
97 map.add("ko-kr", 0x0412);
98 map.add("ru", 0x0019);
99 map.add("ru-ru", 0x0419);
100 map.add("zh-cn", 0x0804);
101 map.add("zh-tw", 0x0404);
102 }
103
104 // Fallback implementation of LocaleNameToLCID API. This is used for
105 // testing on Windows XP.
106 // FIXME: Remove this, ensureNameToLCIDMap, and removeLastComponent when we drop
107 // Windows XP support.
108 static LCID WINAPI convertLocaleNameToLCID(LPCWSTR name, DWORD)
109 {
110 if (!name || !name[0])
111 return LOCALE_USER_DEFAULT;
112 DEFINE_STATIC_LOCAL(NameToLCIDMap, map, ());
113 ensureNameToLCIDMap(map);
114 String localeName = String(name).replace('_', '-');
115 localeName.makeLower();
116 do {
117 NameToLCIDMap::const_iterator iterator = map.find(localeName);
118 if (iterator != map.end())
119 return iterator->value;
120 localeName = removeLastComponent(localeName);
121 } while (!localeName.isEmpty());
122 return LOCALE_USER_DEFAULT;
123 }
124
125 static LCID LCIDFromLocaleInternal(LCID userDefaultLCID, const String& userDefau ltLanguageCode, LocaleNameToLCIDPtr localeNameToLCID, String& locale)
126 {
127 String localeLanguageCode = extractLanguageCode(locale);
128 if (equalIgnoringCase(localeLanguageCode, userDefaultLanguageCode))
129 return userDefaultLCID;
130 return localeNameToLCID(locale.charactersWithNullTermination().data(), 0);
131 }
132
133 static LCID LCIDFromLocale(const AtomicString& locale, bool defaultsForLocale)
134 {
135 // LocaleNameToLCID() is available since Windows Vista.
136 LocaleNameToLCIDPtr localeNameToLCID = reinterpret_cast<LocaleNameToLCIDPtr> (::GetProcAddress(::GetModuleHandle(L"kernel32"), "LocaleNameToLCID"));
137 if (!localeNameToLCID)
138 localeNameToLCID = convertLocaleNameToLCID;
139
140 // According to MSDN, 9 is enough for LOCALE_SISO639LANGNAME.
141 const size_t languageCodeBufferSize = 9;
142 WCHAR lowercaseLanguageCode[languageCodeBufferSize];
143 ::GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME | (defaultsForLo cale ? LOCALE_NOUSEROVERRIDE : 0), lowercaseLanguageCode, languageCodeBufferSize );
144 String userDefaultLanguageCode = String(lowercaseLanguageCode);
145
146 LCID lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageC ode, localeNameToLCID, String(locale));
147 if (!lcid)
148 lcid = LCIDFromLocaleInternal(LOCALE_USER_DEFAULT, userDefaultLanguageCo de, localeNameToLCID, defaultLanguage());
149 return lcid;
150 }
151
152 PassOwnPtr<Locale> Locale::create(const AtomicString& locale)
153 {
154 // Whether the default settings for the locale should be used, ignoring user overrides.
155 bool defaultsForLocale = isRunningLayoutTest();
156 return LocaleWin::create(LCIDFromLocale(locale, defaultsForLocale), defaults ForLocale);
157 }
158
159 inline LocaleWin::LocaleWin(LCID lcid, bool defaultsForLocale)
160 : m_lcid(lcid)
161 , m_didInitializeNumberData(false)
162 , m_defaultsForLocale(defaultsForLocale)
163 {
164 #if ENABLE(CALENDAR_PICKER)
165 DWORD value = 0;
166 getLocaleInfo(LOCALE_IFIRSTDAYOFWEEK | (defaultsForLocale ? LOCALE_NOUSEROVE RRIDE : 0), value);
167 // 0:Monday, ..., 6:Sunday.
168 // We need 1 for Monday, 0 for Sunday.
169 m_firstDayOfWeek = (value + 1) % 7;
170 #endif
171 }
172
173 PassOwnPtr<LocaleWin> LocaleWin::create(LCID lcid, bool defaultsForLocale)
174 {
175 return adoptPtr(new LocaleWin(lcid, defaultsForLocale));
176 }
177
178 LocaleWin::~LocaleWin()
179 {
180 }
181
182 String LocaleWin::getLocaleInfoString(LCTYPE type)
183 {
184 int bufferSizeWithNUL = ::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), 0, 0);
185 if (bufferSizeWithNUL <= 0)
186 return String();
187 StringBuffer<UChar> buffer(bufferSizeWithNUL);
188 ::GetLocaleInfo(m_lcid, type | (m_defaultsForLocale ? LOCALE_NOUSEROVERRIDE : 0), buffer.characters(), bufferSizeWithNUL);
189 buffer.shrink(bufferSizeWithNUL - 1);
190 return String::adopt(buffer);
191 }
192
193 void LocaleWin::getLocaleInfo(LCTYPE type, DWORD& result)
194 {
195 ::GetLocaleInfo(m_lcid, type | LOCALE_RETURN_NUMBER, reinterpret_cast<LPWSTR >(&result), sizeof(DWORD) / sizeof(TCHAR));
196 }
197
198 void LocaleWin::ensureShortMonthLabels()
199 {
200 if (!m_shortMonthLabels.isEmpty())
201 return;
202 const LCTYPE types[12] = {
203 LOCALE_SABBREVMONTHNAME1,
204 LOCALE_SABBREVMONTHNAME2,
205 LOCALE_SABBREVMONTHNAME3,
206 LOCALE_SABBREVMONTHNAME4,
207 LOCALE_SABBREVMONTHNAME5,
208 LOCALE_SABBREVMONTHNAME6,
209 LOCALE_SABBREVMONTHNAME7,
210 LOCALE_SABBREVMONTHNAME8,
211 LOCALE_SABBREVMONTHNAME9,
212 LOCALE_SABBREVMONTHNAME10,
213 LOCALE_SABBREVMONTHNAME11,
214 LOCALE_SABBREVMONTHNAME12,
215 };
216 m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
217 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
218 m_shortMonthLabels.append(getLocaleInfoString(types[i]));
219 if (m_shortMonthLabels.last().isEmpty()) {
220 m_shortMonthLabels.shrink(0);
221 m_shortMonthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthName)) ;
222 for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthName); ++m)
223 m_shortMonthLabels.append(WTF::monthName[m]);
224 return;
225 }
226 }
227 }
228
229 // -------------------------------- Tokenized date format
230
231 static unsigned countContinuousLetters(const String& format, unsigned index)
232 {
233 unsigned count = 1;
234 UChar reference = format[index];
235 while (index + 1 < format.length()) {
236 if (format[++index] != reference)
237 break;
238 ++count;
239 }
240 return count;
241 }
242
243 static void commitLiteralToken(StringBuilder& literalBuffer, StringBuilder& conv erted)
244 {
245 if (literalBuffer.length() <= 0)
246 return;
247 DateTimeFormat::quoteAndAppendLiteral(literalBuffer.toString(), converted);
248 literalBuffer.clear();
249 }
250
251 // This function converts Windows date/time pattern format [1][2] into LDML date
252 // format pattern [3].
253 //
254 // i.e.
255 // We set h, H, m, s, d, dd, M, or y as is. They have same meaning in both of
256 // Windows and LDML.
257 // We need to convert the following patterns:
258 // t -> a
259 // tt -> a
260 // ddd -> EEE
261 // dddd -> EEEE
262 // g -> G
263 // gg -> ignore
264 //
265 // [1] http://msdn.microsoft.com/en-us/library/dd317787(v=vs.85).aspx
266 // [2] http://msdn.microsoft.com/en-us/library/dd318148(v=vs.85).aspx
267 // [3] LDML http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
268 static String convertWindowsDateTimeFormat(const String& format)
269 {
270 StringBuilder converted;
271 StringBuilder literalBuffer;
272 bool inQuote = false;
273 bool lastQuoteCanBeLiteral = false;
274 for (unsigned i = 0; i < format.length(); ++i) {
275 UChar ch = format[i];
276 if (inQuote) {
277 if (ch == '\'') {
278 inQuote = false;
279 ASSERT(i);
280 if (lastQuoteCanBeLiteral && format[i - 1] == '\'') {
281 literalBuffer.append('\'');
282 lastQuoteCanBeLiteral = false;
283 } else {
284 lastQuoteCanBeLiteral = true;
285 }
286 } else {
287 literalBuffer.append(ch);
288 }
289 continue;
290 }
291
292 if (ch == '\'') {
293 inQuote = true;
294 if (lastQuoteCanBeLiteral && i > 0 && format[i - 1] == '\'') {
295 literalBuffer.append(ch);
296 lastQuoteCanBeLiteral = false;
297 } else {
298 lastQuoteCanBeLiteral = true;
299 }
300 } else if (isASCIIAlpha(ch)) {
301 commitLiteralToken(literalBuffer, converted);
302 unsigned symbolStart = i;
303 unsigned count = countContinuousLetters(format, i);
304 i += count - 1;
305 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') {
306 converted.append(format, symbolStart, count);
307 } else if (ch == 'd') {
308 if (count <= 2)
309 converted.append(format, symbolStart, count);
310 else if (count == 3)
311 converted.append("EEE");
312 else
313 converted.append("EEEE");
314 } else if (ch == 'g') {
315 if (count == 1) {
316 converted.append('G');
317 } else {
318 // gg means imperial era in Windows.
319 // Just ignore it.
320 }
321 } else if (ch == 't') {
322 converted.append('a');
323 } else {
324 literalBuffer.append(format, symbolStart, count);
325 }
326 } else {
327 literalBuffer.append(ch);
328 }
329 }
330 commitLiteralToken(literalBuffer, converted);
331 return converted.toString();
332 }
333
334 void LocaleWin::ensureMonthLabels()
335 {
336 if (!m_monthLabels.isEmpty())
337 return;
338 const LCTYPE types[12] = {
339 LOCALE_SMONTHNAME1,
340 LOCALE_SMONTHNAME2,
341 LOCALE_SMONTHNAME3,
342 LOCALE_SMONTHNAME4,
343 LOCALE_SMONTHNAME5,
344 LOCALE_SMONTHNAME6,
345 LOCALE_SMONTHNAME7,
346 LOCALE_SMONTHNAME8,
347 LOCALE_SMONTHNAME9,
348 LOCALE_SMONTHNAME10,
349 LOCALE_SMONTHNAME11,
350 LOCALE_SMONTHNAME12,
351 };
352 m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
353 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
354 m_monthLabels.append(getLocaleInfoString(types[i]));
355 if (m_monthLabels.last().isEmpty()) {
356 m_monthLabels.shrink(0);
357 m_monthLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::monthFullName));
358 for (unsigned m = 0; m < WTF_ARRAY_LENGTH(WTF::monthFullName); ++m)
359 m_monthLabels.append(WTF::monthFullName[m]);
360 return;
361 }
362 }
363 }
364
365 void LocaleWin::ensureWeekDayShortLabels()
366 {
367 if (!m_weekDayShortLabels.isEmpty())
368 return;
369 const LCTYPE types[7] = {
370 LOCALE_SABBREVDAYNAME7, // Sunday
371 LOCALE_SABBREVDAYNAME1, // Monday
372 LOCALE_SABBREVDAYNAME2,
373 LOCALE_SABBREVDAYNAME3,
374 LOCALE_SABBREVDAYNAME4,
375 LOCALE_SABBREVDAYNAME5,
376 LOCALE_SABBREVDAYNAME6
377 };
378 m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(types));
379 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(types); ++i) {
380 m_weekDayShortLabels.append(getLocaleInfoString(types[i]));
381 if (m_weekDayShortLabels.last().isEmpty()) {
382 m_weekDayShortLabels.shrink(0);
383 m_weekDayShortLabels.reserveCapacity(WTF_ARRAY_LENGTH(WTF::weekdayNa me));
384 for (unsigned w = 0; w < WTF_ARRAY_LENGTH(WTF::weekdayName); ++w) {
385 // weekdayName starts with Monday.
386 m_weekDayShortLabels.append(WTF::weekdayName[(w + 6) % 7]);
387 }
388 return;
389 }
390 }
391 }
392
393 const Vector<String>& LocaleWin::monthLabels()
394 {
395 ensureMonthLabels();
396 return m_monthLabels;
397 }
398
399 #if ENABLE(CALENDAR_PICKER)
400 const Vector<String>& LocaleWin::weekDayShortLabels()
401 {
402 ensureWeekDayShortLabels();
403 return m_weekDayShortLabels;
404 }
405
406 unsigned LocaleWin::firstDayOfWeek()
407 {
408 return m_firstDayOfWeek;
409 }
410
411 bool LocaleWin::isRTL()
412 {
413 WTF::Unicode::Direction dir = WTF::Unicode::direction(monthLabels()[0][0]);
414 return dir == WTF::Unicode::RightToLeft || dir == WTF::Unicode::RightToLeftA rabic;
415 }
416 #endif
417
418 String LocaleWin::dateFormat()
419 {
420 if (m_dateFormat.isNull())
421 m_dateFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_S SHORTDATE));
422 return m_dateFormat;
423 }
424
425 String LocaleWin::dateFormat(const String& windowsFormat)
426 {
427 return convertWindowsDateTimeFormat(windowsFormat);
428 }
429
430 String LocaleWin::monthFormat()
431 {
432 if (m_monthFormat.isNull())
433 m_monthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LOCALE_ SYEARMONTH));
434 return m_monthFormat;
435 }
436
437 String LocaleWin::shortMonthFormat()
438 {
439 if (m_shortMonthFormat.isNull())
440 m_shortMonthFormat = convertWindowsDateTimeFormat(getLocaleInfoString(LO CALE_SYEARMONTH)).replace("MMMM", "MMM");
441 return m_shortMonthFormat;
442 }
443
444 String LocaleWin::timeFormat()
445 {
446 if (m_timeFormatWithSeconds.isNull())
447 m_timeFormatWithSeconds = convertWindowsDateTimeFormat(getLocaleInfoStri ng(LOCALE_STIMEFORMAT));
448 return m_timeFormatWithSeconds;
449 }
450
451 String LocaleWin::shortTimeFormat()
452 {
453 if (!m_timeFormatWithoutSeconds.isNull())
454 return m_timeFormatWithoutSeconds;
455 String format = getLocaleInfoString(LOCALE_SSHORTTIME);
456 // Vista or older Windows doesn't support LOCALE_SSHORTTIME.
457 if (format.isEmpty()) {
458 format = getLocaleInfoString(LOCALE_STIMEFORMAT);
459 StringBuilder builder;
460 builder.append(getLocaleInfoString(LOCALE_STIME));
461 builder.append("ss");
462 size_t pos = format.reverseFind(builder.toString());
463 if (pos != kNotFound)
464 format.remove(pos, builder.length());
465 }
466 m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format);
467 return m_timeFormatWithoutSeconds;
468 }
469
470 String LocaleWin::dateTimeFormatWithSeconds()
471 {
472 if (!m_dateTimeFormatWithSeconds.isNull())
473 return m_dateTimeFormatWithSeconds;
474 StringBuilder builder;
475 builder.append(dateFormat());
476 builder.append(' ');
477 builder.append(timeFormat());
478 m_dateTimeFormatWithSeconds = builder.toString();
479 return m_dateTimeFormatWithSeconds;
480 }
481
482 String LocaleWin::dateTimeFormatWithoutSeconds()
483 {
484 if (!m_dateTimeFormatWithoutSeconds.isNull())
485 return m_dateTimeFormatWithoutSeconds;
486 StringBuilder builder;
487 builder.append(dateFormat());
488 builder.append(' ');
489 builder.append(shortTimeFormat());
490 m_dateTimeFormatWithoutSeconds = builder.toString();
491 return m_dateTimeFormatWithoutSeconds;
492 }
493
494 const Vector<String>& LocaleWin::shortMonthLabels()
495 {
496 ensureShortMonthLabels();
497 return m_shortMonthLabels;
498 }
499
500 const Vector<String>& LocaleWin::standAloneMonthLabels()
501 {
502 // Windows doesn't provide a way to get stand-alone month labels.
503 return monthLabels();
504 }
505
506 const Vector<String>& LocaleWin::shortStandAloneMonthLabels()
507 {
508 // Windows doesn't provide a way to get stand-alone month labels.
509 return shortMonthLabels();
510 }
511
512 const Vector<String>& LocaleWin::timeAMPMLabels()
513 {
514 if (m_timeAMPMLabels.isEmpty()) {
515 m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S1159));
516 m_timeAMPMLabels.append(getLocaleInfoString(LOCALE_S2359));
517 }
518 return m_timeAMPMLabels;
519 }
520
521 void LocaleWin::initializeLocaleData()
522 {
523 if (m_didInitializeNumberData)
524 return;
525
526 Vector<String, DecimalSymbolsSize> symbols;
527 enum DigitSubstitution {
528 DigitSubstitutionContext = 0,
529 DigitSubstitution0to9 = 1,
530 DigitSubstitutionNative = 2,
531 };
532 DWORD digitSubstitution = DigitSubstitution0to9;
533 getLocaleInfo(LOCALE_IDIGITSUBSTITUTION, digitSubstitution);
534 if (digitSubstitution == DigitSubstitution0to9) {
535 symbols.append("0");
536 symbols.append("1");
537 symbols.append("2");
538 symbols.append("3");
539 symbols.append("4");
540 symbols.append("5");
541 symbols.append("6");
542 symbols.append("7");
543 symbols.append("8");
544 symbols.append("9");
545 } else {
546 String digits = getLocaleInfoString(LOCALE_SNATIVEDIGITS);
547 ASSERT(digits.length() >= 10);
548 for (unsigned i = 0; i < 10; ++i)
549 symbols.append(digits.substring(i, 1));
550 }
551 ASSERT(symbols.size() == DecimalSeparatorIndex);
552 symbols.append(getLocaleInfoString(LOCALE_SDECIMAL));
553 ASSERT(symbols.size() == GroupSeparatorIndex);
554 symbols.append(getLocaleInfoString(LOCALE_STHOUSAND));
555 ASSERT(symbols.size() == DecimalSymbolsSize);
556
557 String negativeSign = getLocaleInfoString(LOCALE_SNEGATIVESIGN);
558 enum NegativeFormat {
559 NegativeFormatParenthesis = 0,
560 NegativeFormatSignPrefix = 1,
561 NegativeFormatSignSpacePrefix = 2,
562 NegativeFormatSignSuffix = 3,
563 NegativeFormatSpaceSignSuffix = 4,
564 };
565 DWORD negativeFormat = NegativeFormatSignPrefix;
566 getLocaleInfo(LOCALE_INEGNUMBER, negativeFormat);
567 String negativePrefix = emptyString();
568 String negativeSuffix = emptyString();
569 switch (negativeFormat) {
570 case NegativeFormatParenthesis:
571 negativePrefix = "(";
572 negativeSuffix = ")";
573 break;
574 case NegativeFormatSignSpacePrefix:
575 negativePrefix = negativeSign + " ";
576 break;
577 case NegativeFormatSignSuffix:
578 negativeSuffix = negativeSign;
579 break;
580 case NegativeFormatSpaceSignSuffix:
581 negativeSuffix = " " + negativeSign;
582 break;
583 case NegativeFormatSignPrefix: // Fall through.
584 default:
585 negativePrefix = negativeSign;
586 break;
587 }
588 m_didInitializeNumberData = true;
589 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix);
590 }
591
592 }
OLDNEW
« no previous file with comments | « Source/core/platform/text/LocaleWin.h ('k') | Source/core/platform/text/PlatformLocale.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698