diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 16:23:18 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 16:23:18 +0000 |
commit | 70edb8606702fd26565cc46fd3075bfe75f68d97 (patch) | |
tree | c2647cc5cd843c5abbc9c90bd6855bd8b0b7c674 /base/i18n | |
parent | 05672cafff847dc3beb0e29e1506bee6a5a7447e (diff) | |
download | chromium_src-70edb8606702fd26565cc46fd3075bfe75f68d97.zip chromium_src-70edb8606702fd26565cc46fd3075bfe75f68d97.tar.gz chromium_src-70edb8606702fd26565cc46fd3075bfe75f68d97.tar.bz2 |
Convert GetDisplayStringInLTRDirectionality from wstring to string16.
BUG=23581
Review URL: http://codereview.chromium.org/3108027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56535 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/i18n')
-rw-r--r-- | base/i18n/rtl.cc | 10 | ||||
-rw-r--r-- | base/i18n/rtl.h | 7 | ||||
-rw-r--r-- | base/i18n/rtl_unittest.cc | 9 |
3 files changed, 15 insertions, 11 deletions
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc index 6c3d3948..f5381a2 100644 --- a/base/i18n/rtl.cc +++ b/base/i18n/rtl.cc @@ -269,10 +269,12 @@ void WrapPathWithLTRFormatting(const FilePath& path, rtl_safe_path->push_back(kPopDirectionalFormatting); } -std::wstring GetDisplayStringInLTRDirectionality(std::wstring* text) { - if (IsRTL()) - WrapStringWithLTRFormatting(text); - return *text; +string16 GetDisplayStringInLTRDirectionality(const string16& text) { + if (!IsRTL()) + return text; + string16 text_mutable(text); + WrapStringWithLTRFormatting(&text_mutable); + return text_mutable; } const string16 StripWrappingBidiControlCharacters(const string16& text) { diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h index 19b142c..2fe932c 100644 --- a/base/i18n/rtl.h +++ b/base/i18n/rtl.h @@ -6,6 +6,7 @@ #define BASE_I18N_RTL_H_ #pragma once +#include "base/compiler_specific.h" #include "base/string16.h" #include "build/build_config.h" @@ -135,14 +136,16 @@ void WrapPathWithLTRFormatting(const FilePath& path, // string is wrapped with LRE (Left-To-Right Embedding) and PDF (Pop // Directional Formatting) marks and returned. In LTR locale, the string itself // is returned. -std::wstring GetDisplayStringInLTRDirectionality(std::wstring* text); +string16 GetDisplayStringInLTRDirectionality(const string16& text) + WARN_UNUSED_RESULT; // Strip the beginning (U+202A..U+202B, U+202D..U+202E) and/or ending (U+202C) // explicit bidi control characters from |text|, if there are any. Otherwise, // return the text itself. Explicit bidi control characters display and have // semantic effect. They can be deleted so they might not always appear in a // pair. -const string16 StripWrappingBidiControlCharacters(const string16& text); +const string16 StripWrappingBidiControlCharacters(const string16& text) + WARN_UNUSED_RESULT; } // namespace i18n } // namespace base diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc index 62de290..061e140 100644 --- a/base/i18n/rtl_unittest.cc +++ b/base/i18n/rtl_unittest.cc @@ -217,13 +217,12 @@ TEST_F(RTLTest, GetDisplayStringInLTRDirectionality) { { L"abc\x05d0\x05d1.jpg", L"\x202a"L"abc\x05d0\x05d1.jpg\x202c" }, }; for (unsigned int i = 0; i < arraysize(test_data); ++i) { - std::wstring input = test_data[i].raw_filename; - std::wstring expected = - base::i18n::GetDisplayStringInLTRDirectionality(&input); + string16 input = WideToUTF16(test_data[i].raw_filename); + string16 expected = base::i18n::GetDisplayStringInLTRDirectionality(input); if (base::i18n::IsRTL()) - EXPECT_EQ(test_data[i].display_string, expected); + EXPECT_EQ(expected, WideToUTF16(test_data[i].display_string)); else - EXPECT_EQ(input, expected); + EXPECT_EQ(expected, input); } } |