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

Side by Side Diff: base/i18n/number_formatting.cc

Issue 339059: Add compiler-specific "examine printf format" attributes to printfs. (Closed)
Patch Set: cleanups Created 11 years, 1 month 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
OLDNEW
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
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
OLDNEW
« no previous file with comments | « base/histogram.cc ('k') | base/process_util.h » ('j') | base/string_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698