| 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 // | 241 // |
| 242 // Note that IsStringUTF8 checks not only if the input is structurally | 242 // Note that IsStringUTF8 checks not only if the input is structurally |
| 243 // valid but also if it doesn't contain any non-character codepoint | 243 // valid but also if it doesn't contain any non-character codepoint |
| 244 // (e.g. U+FFFE). It's done on purpose because all the existing callers want | 244 // (e.g. U+FFFE). It's done on purpose because all the existing callers want |
| 245 // to have the maximum 'discriminating' power from other encodings. If | 245 // to have the maximum 'discriminating' power from other encodings. If |
| 246 // there's a use case for just checking the structural validity, we have to | 246 // there's a use case for just checking the structural validity, we have to |
| 247 // add a new function for that. | 247 // add a new function for that. |
| 248 // | 248 // |
| 249 // IsStringASCII assumes the input is likely all ASCII, and does not leave early | 249 // IsStringASCII assumes the input is likely all ASCII, and does not leave early |
| 250 // if it is not the case. | 250 // if it is not the case. |
| 251 BASE_EXPORT bool IsStringUTF8(const std::string& str); | 251 BASE_EXPORT bool IsStringUTF8(const StringPiece& str); |
| 252 BASE_EXPORT bool IsStringASCII(const StringPiece& str); | 252 BASE_EXPORT bool IsStringASCII(const StringPiece& str); |
| 253 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); | 253 BASE_EXPORT bool IsStringASCII(const StringPiece16& str); |
| 254 // A convenience adaptor for WebStrings, as they don't convert into | 254 // A convenience adaptor for WebStrings, as they don't convert into |
| 255 // StringPieces directly. | 255 // StringPieces directly. |
| 256 BASE_EXPORT bool IsStringASCII(const string16& str); | 256 BASE_EXPORT bool IsStringASCII(const string16& str); |
| 257 #if defined(WCHAR_T_IS_UTF32) | 257 #if defined(WCHAR_T_IS_UTF32) |
| 258 BASE_EXPORT bool IsStringASCII(const std::wstring& str); | 258 BASE_EXPORT bool IsStringASCII(const std::wstring& str); |
| 259 #endif | 259 #endif |
| 260 | 260 |
| 261 // Converts the elements of the given string. This version uses a pointer to | 261 // Converts the elements of the given string. This version uses a pointer to |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 #elif defined(WCHAR_T_IS_UTF32) | 523 #elif defined(WCHAR_T_IS_UTF32) |
| 524 typedef uint32 Unsigned; | 524 typedef uint32 Unsigned; |
| 525 #endif | 525 #endif |
| 526 }; | 526 }; |
| 527 template<> | 527 template<> |
| 528 struct ToUnsigned<short> { | 528 struct ToUnsigned<short> { |
| 529 typedef unsigned short Unsigned; | 529 typedef unsigned short Unsigned; |
| 530 }; | 530 }; |
| 531 | 531 |
| 532 #endif // BASE_STRINGS_STRING_UTIL_H_ | 532 #endif // BASE_STRINGS_STRING_UTIL_H_ |
| OLD | NEW |