diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-25 21:12:06 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-25 21:12:06 +0000 |
commit | bd59d07bba31ad0db0e7b3be96a3462381a2f50a (patch) | |
tree | 934f028bdb9768b30f1eafd6d9d81e04a53b25f7 /base/i18n | |
parent | 938d6a34f7b50e7c9beb588a2a4b34adb03dcf15 (diff) | |
download | chromium_src-bd59d07bba31ad0db0e7b3be96a3462381a2f50a.zip chromium_src-bd59d07bba31ad0db0e7b3be96a3462381a2f50a.tar.gz chromium_src-bd59d07bba31ad0db0e7b3be96a3462381a2f50a.tar.bz2 |
wstring: remove wstring functions from base/i18n/rtl.h
And update callers.
BUG=23581
Review URL: http://codereview.chromium.org/6883140
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/i18n')
-rw-r--r-- | base/i18n/rtl.cc | 52 | ||||
-rw-r--r-- | base/i18n/rtl.h | 15 | ||||
-rw-r--r-- | base/i18n/rtl_unittest.cc | 34 |
3 files changed, 18 insertions, 83 deletions
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc index 12b376d..2712a44 100644 --- a/base/i18n/rtl.cc +++ b/base/i18n/rtl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -157,12 +157,6 @@ TextDirection GetFirstStrongCharacterDirection(const string16& text) { return LEFT_TO_RIGHT; } -#if defined(WCHAR_T_IS_UTF32) -TextDirection GetFirstStrongCharacterDirection(const std::wstring& text) { - return GetFirstStrongCharacterDirection(WideToUTF16(text)); -} -#endif - #if defined(OS_WIN) bool AdjustStringForLocaleDirection(string16* text) { if (!IsRTL() || text->empty()) @@ -230,18 +224,6 @@ bool AdjustStringForLocaleDirection(string16* text) { #endif // !OS_WIN -#if defined(WCHAR_T_IS_UTF32) -bool AdjustStringForLocaleDirection(std::wstring* text) { - string16 temp = WideToUTF16(*text); - if (AdjustStringForLocaleDirection(&temp)) { - // We should only touch the output on success. - *text = UTF16ToWide(temp); - return true; - } - return false; -} -#endif - bool StringContainsStrongRTLChars(const string16& text) { const UChar* string = text.c_str(); size_t length = text.length(); @@ -263,12 +245,6 @@ bool StringContainsStrongRTLChars(const string16& text) { return false; } -#if defined(WCHAR_T_IS_UTF32) -bool StringContainsStrongRTLChars(const std::wstring& text) { - return StringContainsStrongRTLChars(WideToUTF16(text)); -} -#endif - void WrapStringWithLTRFormatting(string16* text) { if (text->empty()) return; @@ -280,19 +256,6 @@ void WrapStringWithLTRFormatting(string16* text) { text->push_back(kPopDirectionalFormatting); } -#if defined(WCHAR_T_IS_UTF32) -void WrapStringWithLTRFormatting(std::wstring* text) { - if (text->empty()) - return; - - // Inserting an LRE (Left-To-Right Embedding) mark as the first character. - text->insert(0, 1, static_cast<wchar_t>(kLeftToRightEmbeddingMark)); - - // Inserting a PDF (Pop Directional Formatting) mark as the last character. - text->push_back(static_cast<wchar_t>(kPopDirectionalFormatting)); -} -#endif - void WrapStringWithRTLFormatting(string16* text) { if (text->empty()) return; @@ -304,19 +267,6 @@ void WrapStringWithRTLFormatting(string16* text) { text->push_back(kPopDirectionalFormatting); } -#if defined(WCHAR_T_IS_UTF32) -void WrapStringWithRTLFormatting(std::wstring* text) { - if (text->empty()) - return; - - // Inserting an RLE (Right-To-Left Embedding) mark as the first character. - text->insert(0, 1, static_cast<wchar_t>(kRightToLeftEmbeddingMark)); - - // Inserting a PDF (Pop Directional Formatting) mark as the last character. - text->push_back(static_cast<wchar_t>(kPopDirectionalFormatting)); -} -#endif - void WrapPathWithLTRFormatting(const FilePath& path, string16* rtl_safe_path) { // Wrap the overall path with LRE-PDF pair which essentialy marks the diff --git a/base/i18n/rtl.h b/base/i18n/rtl.h index 08bbe92..757457a 100644 --- a/base/i18n/rtl.h +++ b/base/i18n/rtl.h @@ -67,9 +67,6 @@ TextDirection GetTextDirectionForLocale(const char* locale_name); // directionality characters. Please refer to http://unicode.org/reports/tr9/ // for more information. TextDirection GetFirstStrongCharacterDirection(const string16& text); -#if defined(WCHAR_T_IS_UTF32) -TextDirection GetFirstStrongCharacterDirection(const std::wstring& text); -#endif // Given the string in |text|, this function modifies the string in place with // the appropriate Unicode formatting marks that mark the string direction @@ -94,33 +91,21 @@ TextDirection GetFirstStrongCharacterDirection(const std::wstring& text); // language support installed by default, inserting the direction Unicode mark // results in Windows displaying squares. bool AdjustStringForLocaleDirection(string16* text); -#if defined(WCHAR_T_IS_UTF32) -bool AdjustStringForLocaleDirection(std::wstring* text); -#endif // Returns true if the string contains at least one character with strong right // to left directionality; that is, a character with either R or AL Unicode // BiDi character type. bool StringContainsStrongRTLChars(const string16& text); -#if defined(WCHAR_T_IS_UTF32) -bool StringContainsStrongRTLChars(const std::wstring& text); -#endif // Wraps a string with an LRE-PDF pair which essentialy marks the string as a // Left-To-Right string. Doing this is useful in order to make sure LTR // strings are rendered properly in an RTL context. void WrapStringWithLTRFormatting(string16* text); -#if defined(WCHAR_T_IS_UTF32) -void WrapStringWithLTRFormatting(std::wstring* text); -#endif // Wraps a string with an RLE-PDF pair which essentialy marks the string as a // Right-To-Left string. Doing this is useful in order to make sure RTL // strings are rendered properly in an LTR context. void WrapStringWithRTLFormatting(string16* text); -#if defined(WCHAR_T_IS_UTF32) -void WrapStringWithRTLFormatting(std::wstring* text); -#endif // Wraps file path to get it to display correctly in RTL UI. All filepaths // should be passed through this function before display in UI for RTL locales. diff --git a/base/i18n/rtl_unittest.cc b/base/i18n/rtl_unittest.cc index 3ee8254..e3d0f5d 100644 --- a/base/i18n/rtl_unittest.cc +++ b/base/i18n/rtl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -24,73 +24,73 @@ class RTLTest : public PlatformTest { TEST_F(RTLTest, GetFirstStrongCharacterDirection) { // Test pure LTR string. - std::wstring string(L"foo bar"); + string16 string(ASCIIToUTF16("foo bar")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type L. - string.assign(L"foo \x05d0 bar"); + string.assign(WideToUTF16(L"foo \x05d0 bar")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type R. - string.assign(L"\x05d0 foo bar"); + string.assign(WideToUTF16(L"\x05d0 foo bar")); EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string which starts with a character with weak directionality // and in which the first character with strong directionality is a character // with type L. - string.assign(L"!foo \x05d0 bar"); + string.assign(WideToUTF16(L"!foo \x05d0 bar")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string which starts with a character with weak directionality // and in which the first character with strong directionality is a character // with type R. - string.assign(L",\x05d0 foo bar"); + string.assign(WideToUTF16(L",\x05d0 foo bar")); EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type LRE. - string.assign(L"\x202a \x05d0 foo bar"); + string.assign(WideToUTF16(L"\x202a \x05d0 foo bar")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type LRO. - string.assign(L"\x202d \x05d0 foo bar"); + string.assign(WideToUTF16(L"\x202d \x05d0 foo bar")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type RLE. - string.assign(L"\x202b foo \x05d0 bar"); + string.assign(WideToUTF16(L"\x202b foo \x05d0 bar")); EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type RLO. - string.assign(L"\x202e foo \x05d0 bar"); + string.assign(WideToUTF16(L"\x202e foo \x05d0 bar")); EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test bidi string in which the first character with strong directionality // is a character with type AL. - string.assign(L"\x0622 foo \x05d0 bar"); + string.assign(WideToUTF16(L"\x0622 foo \x05d0 bar")); EXPECT_EQ(base::i18n::RIGHT_TO_LEFT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test a string without strong directionality characters. - string.assign(L",!.{}"); + string.assign(ASCIIToUTF16(",!.{}")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); // Test empty string. - string.assign(L""); + string.assign(ASCIIToUTF16("")); EXPECT_EQ(base::i18n::LEFT_TO_RIGHT, base::i18n::GetFirstStrongCharacterDirection(string)); @@ -98,9 +98,9 @@ TEST_F(RTLTest, GetFirstStrongCharacterDirection) { // http://demo.icu-project.org/icu-bin/ubrowse?scr=151&b=10910 for more // information). #if defined(WCHAR_T_IS_UTF32) - string.assign(L" ! \x10910" L"abc 123"); + string.assign(WideToUTF16(L" ! \x10910" L"abc 123")); #elif defined(WCHAR_T_IS_UTF16) - string.assign(L" ! \xd802\xdd10" L"abc 123"); + string.assign(WideToUTF16(L" ! \xd802\xdd10" L"abc 123")); #else #error wchar_t should be either UTF-16 or UTF-32 #endif @@ -108,9 +108,9 @@ TEST_F(RTLTest, GetFirstStrongCharacterDirection) { base::i18n::GetFirstStrongCharacterDirection(string)); #if defined(WCHAR_T_IS_UTF32) - string.assign(L" ! \x10401" L"abc 123"); + string.assign(WideToUTF16(L" ! \x10401" L"abc 123")); #elif defined(WCHAR_T_IS_UTF16) - string.assign(L" ! \xd801\xdc01" L"abc 123"); + string.assign(WideToUTF16(L" ! \xd801\xdc01" L"abc 123")); #else #error wchar_t should be either UTF-16 or UTF-32 #endif |