OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // This file defines utility functions for working with strings. | 5 // This file defines utility functions for working with strings. |
6 | 6 |
7 #ifndef BASE_STRING_UTIL_H_ | 7 #ifndef BASE_STRING_UTIL_H_ |
8 #define BASE_STRING_UTIL_H_ | 8 #define BASE_STRING_UTIL_H_ |
9 | 9 |
10 #include <stdarg.h> // va_list | 10 #include <stdarg.h> // va_list |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Searches for CR or LF characters. Removes all contiguous whitespace | 167 // Searches for CR or LF characters. Removes all contiguous whitespace |
168 // strings that contain them. This is useful when trying to deal with text | 168 // strings that contain them. This is useful when trying to deal with text |
169 // copied from terminals. | 169 // copied from terminals. |
170 // Returns |text|, with the following three transformations: | 170 // Returns |text|, with the following three transformations: |
171 // (1) Leading and trailing whitespace is trimmed. | 171 // (1) Leading and trailing whitespace is trimmed. |
172 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace | 172 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace |
173 // sequences containing a CR or LF are trimmed. | 173 // sequences containing a CR or LF are trimmed. |
174 // (3) All other whitespace sequences are converted to single spaces. | 174 // (3) All other whitespace sequences are converted to single spaces. |
175 std::wstring CollapseWhitespace(const std::wstring& text, | 175 std::wstring CollapseWhitespace(const std::wstring& text, |
176 bool trim_sequences_with_line_breaks); | 176 bool trim_sequences_with_line_breaks); |
| 177 string16 CollapseWhitespace(const string16& text, |
| 178 bool trim_sequences_with_line_breaks); |
177 std::string CollapseWhitespaceASCII(const std::string& text, | 179 std::string CollapseWhitespaceASCII(const std::string& text, |
178 bool trim_sequences_with_line_breaks); | 180 bool trim_sequences_with_line_breaks); |
179 | 181 |
180 // These convert between ASCII (7-bit) and Wide/UTF16 strings. | 182 // These convert between ASCII (7-bit) and Wide/UTF16 strings. |
181 std::string WideToASCII(const std::wstring& wide); | 183 std::string WideToASCII(const std::wstring& wide); |
182 std::wstring ASCIIToWide(const base::StringPiece& ascii); | 184 std::wstring ASCIIToWide(const base::StringPiece& ascii); |
183 std::string UTF16ToASCII(const string16& utf16); | 185 std::string UTF16ToASCII(const string16& utf16); |
184 string16 ASCIIToUTF16(const base::StringPiece& ascii); | 186 string16 ASCIIToUTF16(const base::StringPiece& ascii); |
185 | 187 |
186 // Converts the given wide string to the corresponding Latin1. This will fail | 188 // Converts the given wide string to the corresponding Latin1. This will fail |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 #elif defined(WCHAR_T_IS_UTF32) | 607 #elif defined(WCHAR_T_IS_UTF32) |
606 typedef uint32 Unsigned; | 608 typedef uint32 Unsigned; |
607 #endif | 609 #endif |
608 }; | 610 }; |
609 template<> | 611 template<> |
610 struct ToUnsigned<short> { | 612 struct ToUnsigned<short> { |
611 typedef unsigned short Unsigned; | 613 typedef unsigned short Unsigned; |
612 }; | 614 }; |
613 | 615 |
614 #endif // BASE_STRING_UTIL_H_ | 616 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |