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 <string> | 10 #include <string> |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 // Converts the given wide string to the corresponding Latin1. This will fail | 216 // Converts the given wide string to the corresponding Latin1. This will fail |
217 // (return false) if any characters are more than 255. | 217 // (return false) if any characters are more than 255. |
218 bool WideToLatin1(const std::wstring& wide, std::string* latin1); | 218 bool WideToLatin1(const std::wstring& wide, std::string* latin1); |
219 | 219 |
220 // Returns true if the specified string matches the criteria. How can a wide | 220 // Returns true if the specified string matches the criteria. How can a wide |
221 // string be 8-bit or UTF8? It contains only characters that are < 256 (in the | 221 // string be 8-bit or UTF8? It contains only characters that are < 256 (in the |
222 // first case) or characters that use only 8-bits and whose 8-bit | 222 // first case) or characters that use only 8-bits and whose 8-bit |
223 // representation looks like a UTF-8 string (the second case). | 223 // representation looks like a UTF-8 string (the second case). |
224 bool IsString8Bit(const std::wstring& str); | 224 bool IsString8Bit(const std::wstring& str); |
225 bool IsStringUTF8(const char* str); | 225 bool IsStringUTF8(const std::string& str); |
226 bool IsStringWideUTF8(const wchar_t* str); | 226 bool IsStringWideUTF8(const std::wstring& str); |
227 bool IsStringASCII(const std::wstring& str); | 227 bool IsStringASCII(const std::wstring& str); |
228 bool IsStringASCII(const std::string& str); | 228 bool IsStringASCII(const std::string& str); |
229 | 229 |
230 // ASCII-specific tolower. The standard library's tolower is locale sensitive, | 230 // ASCII-specific tolower. The standard library's tolower is locale sensitive, |
231 // so we don't want to use it here. | 231 // so we don't want to use it here. |
232 template <class Char> inline Char ToLowerASCII(Char c) { | 232 template <class Char> inline Char ToLowerASCII(Char c) { |
233 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; | 233 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; |
234 } | 234 } |
235 | 235 |
236 // Converts the elements of the given string. This version uses a pointer to | 236 // Converts the elements of the given string. This version uses a pointer to |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // Returns true if the string passed in matches the pattern. The pattern | 506 // Returns true if the string passed in matches the pattern. The pattern |
507 // string can contain wildcards like * and ? | 507 // string can contain wildcards like * and ? |
508 // TODO(iyengar) This function may not work correctly for CJK strings as | 508 // TODO(iyengar) This function may not work correctly for CJK strings as |
509 // it does individual character matches. | 509 // it does individual character matches. |
510 // The backslash character (\) is an escape character for * and ? | 510 // The backslash character (\) is an escape character for * and ? |
511 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); | 511 bool MatchPattern(const std::wstring& string, const std::wstring& pattern); |
512 bool MatchPattern(const std::string& string, const std::string& pattern); | 512 bool MatchPattern(const std::string& string, const std::string& pattern); |
513 | 513 |
514 #endif // BASE_STRING_UTIL_H_ | 514 #endif // BASE_STRING_UTIL_H_ |
515 | 515 |
OLD | NEW |