| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 // representation looks like a UTF-8 string (the second case). | 240 // representation looks like a UTF-8 string (the second case). |
| 241 // | 241 // |
| 242 // Note that IsStringUTF8 checks not only if the input is structrually | 242 // Note that IsStringUTF8 checks not only if the input is structrually |
| 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 bool IsString8Bit(const std::wstring& str); | 248 bool IsString8Bit(const std::wstring& str); |
| 249 bool IsStringUTF8(const std::string& str); | 249 bool IsStringUTF8(const std::string& str); |
| 250 bool IsStringWideUTF8(const std::wstring& str); | |
| 251 bool IsStringASCII(const std::wstring& str); | 250 bool IsStringASCII(const std::wstring& str); |
| 252 bool IsStringASCII(const base::StringPiece& str); | 251 bool IsStringASCII(const base::StringPiece& str); |
| 253 bool IsStringASCII(const string16& str); | 252 bool IsStringASCII(const string16& str); |
| 254 | 253 |
| 255 // ASCII-specific tolower. The standard library's tolower is locale sensitive, | 254 // ASCII-specific tolower. The standard library's tolower is locale sensitive, |
| 256 // so we don't want to use it here. | 255 // so we don't want to use it here. |
| 257 template <class Char> inline Char ToLowerASCII(Char c) { | 256 template <class Char> inline Char ToLowerASCII(Char c) { |
| 258 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; | 257 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; |
| 259 } | 258 } |
| 260 | 259 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 #elif defined(WCHAR_T_IS_UTF32) | 675 #elif defined(WCHAR_T_IS_UTF32) |
| 677 typedef uint32 Unsigned; | 676 typedef uint32 Unsigned; |
| 678 #endif | 677 #endif |
| 679 }; | 678 }; |
| 680 template<> | 679 template<> |
| 681 struct ToUnsigned<short> { | 680 struct ToUnsigned<short> { |
| 682 typedef unsigned short Unsigned; | 681 typedef unsigned short Unsigned; |
| 683 }; | 682 }; |
| 684 | 683 |
| 685 #endif // BASE_STRING_UTIL_H_ | 684 #endif // BASE_STRING_UTIL_H_ |
| OLD | NEW |