| Index: base/strings/string_util.cc
|
| ===================================================================
|
| --- base/strings/string_util.cc (revision 236429)
|
| +++ base/strings/string_util.cc (working copy)
|
| @@ -193,19 +193,11 @@
|
| ((last_good_char == last_char) ? TRIM_NONE : TRIM_TRAILING));
|
| }
|
|
|
| -bool TrimString(const std::wstring& input,
|
| - const wchar_t trim_chars[],
|
| - std::wstring* output) {
|
| - return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE;
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool TrimString(const string16& input,
|
| const char16 trim_chars[],
|
| string16* output) {
|
| return TrimStringT(input, trim_chars, TRIM_ALL, output) != TRIM_NONE;
|
| }
|
| -#endif
|
|
|
| bool TrimString(const std::string& input,
|
| const char trim_chars[],
|
| @@ -311,17 +303,10 @@
|
| return result;
|
| }
|
|
|
| -std::wstring CollapseWhitespace(const std::wstring& text,
|
| - bool trim_sequences_with_line_breaks) {
|
| - return CollapseWhitespaceT(text, trim_sequences_with_line_breaks);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| string16 CollapseWhitespace(const string16& text,
|
| bool trim_sequences_with_line_breaks) {
|
| return CollapseWhitespaceT(text, trim_sequences_with_line_breaks);
|
| }
|
| -#endif
|
|
|
| std::string CollapseWhitespaceASCII(const std::string& text,
|
| bool trim_sequences_with_line_breaks) {
|
| @@ -350,22 +335,19 @@
|
| return true;
|
| }
|
|
|
| -bool ContainsOnlyChars(const std::wstring& input,
|
| - const std::wstring& characters) {
|
| - return ContainsOnlyCharsT(input, characters);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool ContainsOnlyChars(const string16& input, const string16& characters) {
|
| return ContainsOnlyCharsT(input, characters);
|
| }
|
| -#endif
|
|
|
| bool ContainsOnlyChars(const std::string& input,
|
| const std::string& characters) {
|
| return ContainsOnlyCharsT(input, characters);
|
| }
|
|
|
| +#if !defined(WCHAR_T_IS_UTF16)
|
| +bool IsStringASCII(const std::wstring& str);
|
| +#endif
|
| +
|
| std::string WideToASCII(const std::wstring& wide) {
|
| DCHECK(IsStringASCII(wide)) << wide;
|
| return std::string(wide.begin(), wide.end());
|
| @@ -376,20 +358,6 @@
|
| return std::string(utf16.begin(), utf16.end());
|
| }
|
|
|
| -// Latin1 is just the low range of Unicode, so we can copy directly to convert.
|
| -bool WideToLatin1(const std::wstring& wide, std::string* latin1) {
|
| - std::string output;
|
| - output.resize(wide.size());
|
| - latin1->clear();
|
| - for (size_t i = 0; i < wide.size(); i++) {
|
| - if (wide[i] > 255)
|
| - return false;
|
| - output[i] = static_cast<char>(wide[i]);
|
| - }
|
| - latin1->swap(output);
|
| - return true;
|
| -}
|
| -
|
| template<class STR>
|
| static bool DoIsStringASCII(const STR& str) {
|
| for (size_t i = 0; i < str.length(); i++) {
|
| @@ -400,15 +368,15 @@
|
| return true;
|
| }
|
|
|
| +#if !defined(WCHAR_T_IS_UTF16)
|
| bool IsStringASCII(const std::wstring& str) {
|
| return DoIsStringASCII(str);
|
| }
|
| +#endif
|
|
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool IsStringASCII(const string16& str) {
|
| return DoIsStringASCII(str);
|
| }
|
| -#endif
|
|
|
| bool IsStringASCII(const base::StringPiece& str) {
|
| return DoIsStringASCII(str);
|
| @@ -444,15 +412,9 @@
|
| return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
|
| }
|
|
|
| -bool LowerCaseEqualsASCII(const std::wstring& a, const char* b) {
|
| - return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool LowerCaseEqualsASCII(const string16& a, const char* b) {
|
| return DoLowerCaseEqualsASCII(a.begin(), a.end(), b);
|
| }
|
| -#endif
|
|
|
| bool LowerCaseEqualsASCII(std::string::const_iterator a_begin,
|
| std::string::const_iterator a_end,
|
| @@ -460,19 +422,11 @@
|
| return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| }
|
|
|
| -bool LowerCaseEqualsASCII(std::wstring::const_iterator a_begin,
|
| - std::wstring::const_iterator a_end,
|
| - const char* b) {
|
| - return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool LowerCaseEqualsASCII(string16::const_iterator a_begin,
|
| string16::const_iterator a_end,
|
| const char* b) {
|
| return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| }
|
| -#endif
|
|
|
| // TODO(port): Resolve wchar_t/iterator issues that require OS_ANDROID here.
|
| #if !defined(OS_ANDROID)
|
| @@ -482,19 +436,11 @@
|
| return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| }
|
|
|
| -bool LowerCaseEqualsASCII(const wchar_t* a_begin,
|
| - const wchar_t* a_end,
|
| - const char* b) {
|
| - return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool LowerCaseEqualsASCII(const char16* a_begin,
|
| const char16* a_end,
|
| const char* b) {
|
| return DoLowerCaseEqualsASCII(a_begin, a_end, b);
|
| }
|
| -#endif
|
|
|
| #endif // !defined(OS_ANDROID)
|
|
|
| @@ -525,17 +471,10 @@
|
| }
|
| }
|
|
|
| -bool StartsWith(const std::wstring& str, const std::wstring& search,
|
| - bool case_sensitive) {
|
| - return StartsWithT(str, search, case_sensitive);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool StartsWith(const string16& str, const string16& search,
|
| bool case_sensitive) {
|
| return StartsWithT(str, search, case_sensitive);
|
| }
|
| -#endif
|
|
|
| template <typename STR>
|
| bool EndsWithT(const STR& str, const STR& search, bool case_sensitive) {
|
| @@ -557,17 +496,10 @@
|
| return EndsWithT(str, search, case_sensitive);
|
| }
|
|
|
| -bool EndsWith(const std::wstring& str, const std::wstring& search,
|
| - bool case_sensitive) {
|
| - return EndsWithT(str, search, case_sensitive);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| bool EndsWith(const string16& str, const string16& search,
|
| bool case_sensitive) {
|
| return EndsWithT(str, search, case_sensitive);
|
| }
|
| -#endif
|
|
|
| static const char* const kByteStringsUnlocalized[] = {
|
| " B",
|
| @@ -674,19 +606,11 @@
|
| return tokens->size();
|
| }
|
|
|
| -size_t Tokenize(const std::wstring& str,
|
| - const std::wstring& delimiters,
|
| - std::vector<std::wstring>* tokens) {
|
| - return TokenizeT(str, delimiters, tokens);
|
| -}
|
| -
|
| -#if !defined(WCHAR_T_IS_UTF16)
|
| size_t Tokenize(const string16& str,
|
| const string16& delimiters,
|
| std::vector<string16>* tokens) {
|
| return TokenizeT(str, delimiters, tokens);
|
| }
|
| -#endif
|
|
|
| size_t Tokenize(const std::string& str,
|
| const std::string& delimiters,
|
| @@ -817,10 +741,9 @@
|
| subst.push_back(a);
|
| string16 result = ReplaceStringPlaceholders(format_string, subst, &offsets);
|
|
|
| - DCHECK(offsets.size() == 1);
|
| - if (offset) {
|
| + DCHECK_EQ(1U, offsets.size());
|
| + if (offset)
|
| *offset = offsets[0];
|
| - }
|
| return result;
|
| }
|
|
|
|
|