| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "base/format_macros.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 11 #include "unicode/numfmt.h" | 12 #include "unicode/numfmt.h" |
| 12 #include "unicode/ustring.h" | 13 #include "unicode/ustring.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 } // namespace | 33 } // namespace |
| 33 | 34 |
| 34 string16 FormatNumber(int64 number) { | 35 string16 FormatNumber(int64 number) { |
| 35 icu::NumberFormat* number_format = | 36 icu::NumberFormat* number_format = |
| 36 Singleton<icu::NumberFormat, NumberFormatSingletonTraits>::get(); | 37 Singleton<icu::NumberFormat, NumberFormatSingletonTraits>::get(); |
| 37 | 38 |
| 38 if (!number_format) { | 39 if (!number_format) { |
| 39 // As a fallback, just return the raw number in a string. | 40 // As a fallback, just return the raw number in a string. |
| 40 return UTF8ToUTF16(StringPrintf("%lld", number)); | 41 return UTF8ToUTF16(StringPrintf("%" PRId64, number)); |
| 41 } | 42 } |
| 42 icu::UnicodeString ustr; | 43 icu::UnicodeString ustr; |
| 43 number_format->format(number, ustr); | 44 number_format->format(number, ustr); |
| 44 | 45 |
| 45 return string16(ustr.getBuffer(), static_cast<size_t>(ustr.length())); | 46 return string16(ustr.getBuffer(), static_cast<size_t>(ustr.length())); |
| 46 } | 47 } |
| 47 | 48 |
| 48 } // namespace base | 49 } // namespace base |
| OLD | NEW |