| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 // Searches for CR or LF characters. Removes all contiguous whitespace | 164 // Searches for CR or LF characters. Removes all contiguous whitespace |
| 165 // strings that contain them. This is useful when trying to deal with text | 165 // strings that contain them. This is useful when trying to deal with text |
| 166 // copied from terminals. | 166 // copied from terminals. |
| 167 // Returns |text, with the following three transformations: | 167 // Returns |text, with the following three transformations: |
| 168 // (1) Leading and trailing whitespace is trimmed. | 168 // (1) Leading and trailing whitespace is trimmed. |
| 169 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace | 169 // (2) If |trim_sequences_with_line_breaks| is true, any other whitespace |
| 170 // sequences containing a CR or LF are trimmed. | 170 // sequences containing a CR or LF are trimmed. |
| 171 // (3) All other whitespace sequences are converted to single spaces. | 171 // (3) All other whitespace sequences are converted to single spaces. |
| 172 std::wstring CollapseWhitespace(const std::wstring& text, | 172 std::wstring CollapseWhitespace(const std::wstring& text, |
| 173 bool trim_sequences_with_line_breaks); | 173 bool trim_sequences_with_line_breaks); |
| 174 std::string CollapseWhitespaceASCII(const std::string& text, |
| 175 bool trim_sequences_with_line_breaks); |
| 174 | 176 |
| 175 // These convert between ASCII (7-bit) and Wide/UTF16 strings. | 177 // These convert between ASCII (7-bit) and Wide/UTF16 strings. |
| 176 std::string WideToASCII(const std::wstring& wide); | 178 std::string WideToASCII(const std::wstring& wide); |
| 177 std::wstring ASCIIToWide(const StringPiece& ascii); | 179 std::wstring ASCIIToWide(const StringPiece& ascii); |
| 178 std::string UTF16ToASCII(const string16& utf16); | 180 std::string UTF16ToASCII(const string16& utf16); |
| 179 string16 ASCIIToUTF16(const StringPiece& ascii); | 181 string16 ASCIIToUTF16(const StringPiece& ascii); |
| 180 | 182 |
| 181 // These convert between UTF-8, -16, and -32 strings. They are potentially slow, | 183 // These convert between UTF-8, -16, and -32 strings. They are potentially slow, |
| 182 // so avoid unnecessary conversions. The low-level versions return a boolean | 184 // so avoid unnecessary conversions. The low-level versions return a boolean |
| 183 // indicating whether the conversion was 100% valid. In this case, it will still | 185 // indicating whether the conversion was 100% valid. In this case, it will still |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 #elif defined(WCHAR_T_IS_UTF32) | 620 #elif defined(WCHAR_T_IS_UTF32) |
| 619 typedef uint32 Unsigned; | 621 typedef uint32 Unsigned; |
| 620 #endif | 622 #endif |
| 621 }; | 623 }; |
| 622 template<> | 624 template<> |
| 623 struct ToUnsigned<short> { | 625 struct ToUnsigned<short> { |
| 624 typedef unsigned short Unsigned; | 626 typedef unsigned short Unsigned; |
| 625 }; | 627 }; |
| 626 | 628 |
| 627 #endif // BASE_STRING_UTIL_H_ | 629 #endif // BASE_STRING_UTIL_H_ |
| OLD | NEW |