Chromium Code Reviews| Index: content/renderer/date_time_formatter.cc |
| diff --git a/content/renderer/date_time_formatter.cc b/content/renderer/date_time_formatter.cc |
| index eca5b9773e8bcf2deb35f041d3c4472bd3c00cee..9218f8e905135f182e7fb68b22359ca4702c4676 100644 |
| --- a/content/renderer/date_time_formatter.cc |
| +++ b/content/renderer/date_time_formatter.cc |
| @@ -5,6 +5,7 @@ |
| #include "content/renderer/date_time_formatter.h" |
| #include "base/string_util.h" |
| +#include "base/utf_string_conversions.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebCString.h" |
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebDateTimeChooserParams.h" |
| #include "third_party/icu/public/i18n/unicode/smpdtfmt.h" |
| @@ -52,8 +53,6 @@ DateTimeFormatter::DateTimeFormatter( |
| pattern_ = type_ > 0 && type_ <= ui::TEXT_INPUT_TYPE_MAX ? |
| &patterns_[type_] : &patterns_[ui::TEXT_INPUT_TYPE_NONE]; |
| - std::string patt; |
| - pattern_->toUTF8String(patt); |
| formatted_string_ = FormatString(); |
| } |
| @@ -107,7 +106,8 @@ const std::string DateTimeFormatter::FormatString() const { |
| icu::SimpleDateFormat formatter(*pattern_, success); |
| icu::UnicodeString formattedTime; |
| formatter.format(time, formattedTime, success); |
| - formattedTime.toUTF8String(result); |
| + result = UTF16ToUTF8(string16(formattedTime.getBuffer(), |
|
Miguel Garcia
2013/02/08 10:09:18
Can you add a comment on why we need to convert to
benm (inactive)
2013/02/08 10:22:08
I guess we can mitigate this perf impact with an i
|
| + static_cast<size_t>(formattedTime.length()))); |
| if (success <= U_ZERO_ERROR) |
| return result; |
| } |
| @@ -162,7 +162,7 @@ bool DateTimeFormatter::ParseValues() { |
| UErrorCode success = U_ZERO_ERROR; |
| icu::UnicodeString icu_value = |
| - icu::UnicodeString::fromUTF8(formatted_string_); |
| + icu::UnicodeString::fromUTF8(formatted_string_.c_str()); |
| if (type_ > 0 && type_ <= ui::TEXT_INPUT_TYPE_MAX) { |
| const icu::UnicodeString pattern = patterns_[type_]; |
| icu::SimpleDateFormat formatter(pattern, success); |