| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/i18n/number_formatting.h" | 5 #include "base/i18n/number_formatting.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 |
| 7 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 8 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 14 #include "third_party/icu/source/common/unicode/ustring.h" | 16 #include "third_party/icu/source/common/unicode/ustring.h" |
| 15 #include "third_party/icu/source/i18n/unicode/numfmt.h" | 17 #include "third_party/icu/source/i18n/unicode/numfmt.h" |
| 16 | 18 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 38 scoped_ptr<icu::NumberFormat> number_format; | 40 scoped_ptr<icu::NumberFormat> number_format; |
| 39 }; | 41 }; |
| 40 | 42 |
| 41 LazyInstance<NumberFormatWrapper> g_number_format_int = | 43 LazyInstance<NumberFormatWrapper> g_number_format_int = |
| 42 LAZY_INSTANCE_INITIALIZER; | 44 LAZY_INSTANCE_INITIALIZER; |
| 43 LazyInstance<NumberFormatWrapper> g_number_format_float = | 45 LazyInstance<NumberFormatWrapper> g_number_format_float = |
| 44 LAZY_INSTANCE_INITIALIZER; | 46 LAZY_INSTANCE_INITIALIZER; |
| 45 | 47 |
| 46 } // namespace | 48 } // namespace |
| 47 | 49 |
| 48 string16 FormatNumber(int64 number) { | 50 string16 FormatNumber(int64_t number) { |
| 49 icu::NumberFormat* number_format = | 51 icu::NumberFormat* number_format = |
| 50 g_number_format_int.Get().number_format.get(); | 52 g_number_format_int.Get().number_format.get(); |
| 51 | 53 |
| 52 if (!number_format) { | 54 if (!number_format) { |
| 53 // As a fallback, just return the raw number in a string. | 55 // As a fallback, just return the raw number in a string. |
| 54 return UTF8ToUTF16(StringPrintf("%" PRId64, number)); | 56 return UTF8ToUTF16(StringPrintf("%" PRId64, number)); |
| 55 } | 57 } |
| 56 icu::UnicodeString ustr; | 58 icu::UnicodeString ustr; |
| 57 number_format->format(number, ustr); | 59 number_format->format(number, ustr); |
| 58 | 60 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 78 namespace testing { | 80 namespace testing { |
| 79 | 81 |
| 80 void ResetFormatters() { | 82 void ResetFormatters() { |
| 81 g_number_format_int.Get().Reset(); | 83 g_number_format_int.Get().Reset(); |
| 82 g_number_format_float.Get().Reset(); | 84 g_number_format_float.Get().Reset(); |
| 83 } | 85 } |
| 84 | 86 |
| 85 } // namespace testing | 87 } // namespace testing |
| 86 | 88 |
| 87 } // namespace base | 89 } // namespace base |
| OLD | NEW |