| Index: ui/base/resource/resource_bundle.cc
|
| diff --git a/ui/base/resource/resource_bundle.cc b/ui/base/resource/resource_bundle.cc
|
| index 7ae0f4e045f0d22e1fad85bb9917493b7828197c..f1722ffd5b95e0c3dcd7d730de9c1460c1897007 100644
|
| --- a/ui/base/resource/resource_bundle.cc
|
| +++ b/ui/base/resource/resource_bundle.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/stl_util.h"
|
| #include "base/string_piece.h"
|
| #include "base/synchronization/lock.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "build/build_config.h"
|
| #include "third_party/skia/include/core/SkBitmap.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -187,10 +188,19 @@ string16 ResourceBundle::GetLocalizedString(int message_id) {
|
| }
|
| }
|
|
|
| - // Data pack encodes strings as UTF16.
|
| - DCHECK_EQ(data.length() % 2, 0U);
|
| - string16 msg(reinterpret_cast<const char16*>(data.data()),
|
| - data.length() / 2);
|
| + // Strings should not be loaded from a data pack that contains binary data.
|
| + DCHECK(locale_resources_data_->GetTextEncodingType() == DataPack::UTF16 ||
|
| + locale_resources_data_->GetTextEncodingType() == DataPack::UTF8)
|
| + << "requested localized string from binary pack file";
|
| +
|
| + // Data pack encodes strings as either UTF8 or UTF16.
|
| + string16 msg;
|
| + if (locale_resources_data_->GetTextEncodingType() == DataPack::UTF16) {
|
| + msg = string16(reinterpret_cast<const char16*>(data.data()),
|
| + data.length() / 2);
|
| + } else if (locale_resources_data_->GetTextEncodingType() == DataPack::UTF8) {
|
| + msg = UTF8ToUTF16(data);
|
| + }
|
| return msg;
|
| }
|
|
|
|
|