| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_STRINGS_STRING_UTIL_H_ | 7 #ifndef BASE_STRINGS_STRING_UTIL_H_ |
| 8 #define BASE_STRINGS_STRING_UTIL_H_ | 8 #define BASE_STRINGS_STRING_UTIL_H_ |
| 9 | 9 |
| 10 #include <ctype.h> | 10 #include <ctype.h> |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // (e.g. U+FFFE). It's done on purpose because all the existing callers want | 277 // (e.g. U+FFFE). It's done on purpose because all the existing callers want |
| 278 // to have the maximum 'discriminating' power from other encodings. If | 278 // to have the maximum 'discriminating' power from other encodings. If |
| 279 // there's a use case for just checking the structural validity, we have to | 279 // there's a use case for just checking the structural validity, we have to |
| 280 // add a new function for that. | 280 // add a new function for that. |
| 281 // | 281 // |
| 282 // IsStringASCII assumes the input is likely all ASCII, and does not leave early | 282 // IsStringASCII assumes the input is likely all ASCII, and does not leave early |
| 283 // if it is not the case. | 283 // if it is not the case. |
| 284 BASE_EXPORT bool IsStringUTF8(const StringPiece& str); | 284 BASE_EXPORT bool IsStringUTF8(const StringPiece& str); |
| 285 BASE_EXPORT bool IsStringASCII(const StringPiece& str); | 285 BASE_EXPORT bool IsStringASCII(const StringPiece& str); |
| 286 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); | 286 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); |
| 287 // A convenience adaptor for WebStrings, as they don't convert into | |
| 288 // StringPieces directly. | |
| 289 BASE_EXPORT bool IsStringASCII(const string16& str); | 287 BASE_EXPORT bool IsStringASCII(const string16& str); |
| 290 #if defined(WCHAR_T_IS_UTF32) | 288 #if defined(WCHAR_T_IS_UTF32) |
| 291 BASE_EXPORT bool IsStringASCII(const std::wstring& str); | 289 BASE_EXPORT bool IsStringASCII(const std::wstring& str); |
| 292 #endif | 290 #endif |
| 293 | 291 |
| 294 // Compare the lower-case form of the given string against the given | 292 // Compare the lower-case form of the given string against the given |
| 295 // previously-lower-cased ASCII string (typically a constant). | 293 // previously-lower-cased ASCII string (typically a constant). |
| 296 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, | 294 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, |
| 297 StringPiece lowecase_ascii); | 295 StringPiece lowecase_ascii); |
| 298 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str, | 296 BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece16 str, |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 458 |
| 461 #if defined(OS_WIN) | 459 #if defined(OS_WIN) |
| 462 #include "base/strings/string_util_win.h" | 460 #include "base/strings/string_util_win.h" |
| 463 #elif defined(OS_POSIX) | 461 #elif defined(OS_POSIX) |
| 464 #include "base/strings/string_util_posix.h" | 462 #include "base/strings/string_util_posix.h" |
| 465 #else | 463 #else |
| 466 #error Define string operations appropriately for your platform | 464 #error Define string operations appropriately for your platform |
| 467 #endif | 465 #endif |
| 468 | 466 |
| 469 #endif // BASE_STRINGS_STRING_UTIL_H_ | 467 #endif // BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |