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

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

Issue 2740673002: Prepare Chromium and Blink for ICU 59 (Closed)
Patch Set: revert accidental revert of sftnly roll during rebase Created 3 years, 9 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 | « base/BUILD.gn ('k') | base/i18n/number_formatting.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/message_formatter.h" 5 #include "base/i18n/message_formatter.h"
6 6
7 #include "base/i18n/unicodestring.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
9 #include "base/time/time.h" 10 #include "base/time/time.h"
10 #include "third_party/icu/source/common/unicode/unistr.h" 11 #include "third_party/icu/source/common/unicode/unistr.h"
11 #include "third_party/icu/source/common/unicode/utypes.h" 12 #include "third_party/icu/source/common/unicode/utypes.h"
12 #include "third_party/icu/source/i18n/unicode/fmtable.h" 13 #include "third_party/icu/source/i18n/unicode/fmtable.h"
13 #include "third_party/icu/source/i18n/unicode/msgfmt.h" 14 #include "third_party/icu/source/i18n/unicode/msgfmt.h"
14 15
15 using icu::UnicodeString; 16 using icu::UnicodeString;
16 17
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 UErrorCode error = U_ZERO_ERROR; 85 UErrorCode error = U_ZERO_ERROR;
85 icu::MessageFormat format(msg_string, error); 86 icu::MessageFormat format(msg_string, error);
86 icu::UnicodeString formatted; 87 icu::UnicodeString formatted;
87 icu::FieldPosition ignore(icu::FieldPosition::DONT_CARE); 88 icu::FieldPosition ignore(icu::FieldPosition::DONT_CARE);
88 format.format(args, args_count, formatted, ignore, error); 89 format.format(args, args_count, formatted, ignore, error);
89 if (U_FAILURE(error)) { 90 if (U_FAILURE(error)) {
90 LOG(ERROR) << "MessageFormat(" << msg.as_string() << ") failed with " 91 LOG(ERROR) << "MessageFormat(" << msg.as_string() << ") failed with "
91 << u_errorName(error); 92 << u_errorName(error);
92 return string16(); 93 return string16();
93 } 94 }
94 return string16(formatted.getBuffer(), formatted.length()); 95 return i18n::UnicodeStringToString16(formatted);
95 } 96 }
96 97
97 string16 MessageFormatter::FormatWithNamedArgs( 98 string16 MessageFormatter::FormatWithNamedArgs(
98 StringPiece16 msg, 99 StringPiece16 msg,
99 StringPiece name0, const internal::MessageArg& arg0, 100 StringPiece name0, const internal::MessageArg& arg0,
100 StringPiece name1, const internal::MessageArg& arg1, 101 StringPiece name1, const internal::MessageArg& arg1,
101 StringPiece name2, const internal::MessageArg& arg2, 102 StringPiece name2, const internal::MessageArg& arg2,
102 StringPiece name3, const internal::MessageArg& arg3, 103 StringPiece name3, const internal::MessageArg& arg3,
103 StringPiece name4, const internal::MessageArg& arg4, 104 StringPiece name4, const internal::MessageArg& arg4,
104 StringPiece name5, const internal::MessageArg& arg5, 105 StringPiece name5, const internal::MessageArg& arg5,
(...skipping 22 matching lines...) Expand all
127 UErrorCode error = U_ZERO_ERROR; 128 UErrorCode error = U_ZERO_ERROR;
128 icu::MessageFormat format(msg_string, error); 129 icu::MessageFormat format(msg_string, error);
129 130
130 icu::UnicodeString formatted; 131 icu::UnicodeString formatted;
131 format.format(names, args, args_count, formatted, error); 132 format.format(names, args, args_count, formatted, error);
132 if (U_FAILURE(error)) { 133 if (U_FAILURE(error)) {
133 LOG(ERROR) << "MessageFormat(" << msg.as_string() << ") failed with " 134 LOG(ERROR) << "MessageFormat(" << msg.as_string() << ") failed with "
134 << u_errorName(error); 135 << u_errorName(error);
135 return string16(); 136 return string16();
136 } 137 }
137 return string16(formatted.getBuffer(), formatted.length()); 138 return i18n::UnicodeStringToString16(formatted);
138 } 139 }
139 140
140 } // namespace i18n 141 } // namespace i18n
141 } // namespace base 142 } // namespace base
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/i18n/number_formatting.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698