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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // representation looks like a UTF-8 string (the second case). | 220 // representation looks like a UTF-8 string (the second case). |
221 // | 221 // |
222 // Note that IsStringUTF8 checks not only if the input is structrually | 222 // Note that IsStringUTF8 checks not only if the input is structrually |
223 // valid but also if it doesn't contain any non-character codepoint | 223 // valid but also if it doesn't contain any non-character codepoint |
224 // (e.g. U+FFFE). It's done on purpose because all the existing callers want | 224 // (e.g. U+FFFE). It's done on purpose because all the existing callers want |
225 // to have the maximum 'discriminating' power from other encodings. If | 225 // to have the maximum 'discriminating' power from other encodings. If |
226 // there's a use case for just checking the structural validity, we have to | 226 // there's a use case for just checking the structural validity, we have to |
227 // add a new function for that. | 227 // add a new function for that. |
228 bool IsString8Bit(const std::wstring& str); | 228 bool IsString8Bit(const std::wstring& str); |
229 bool IsStringUTF8(const std::string& str); | 229 bool IsStringUTF8(const std::string& str); |
| 230 bool IsStringWideUTF8(const std::wstring& str); |
230 bool IsStringASCII(const std::wstring& str); | 231 bool IsStringASCII(const std::wstring& str); |
231 bool IsStringASCII(const base::StringPiece& str); | 232 bool IsStringASCII(const base::StringPiece& str); |
232 bool IsStringASCII(const string16& str); | 233 bool IsStringASCII(const string16& str); |
233 | 234 |
234 // ASCII-specific tolower. The standard library's tolower is locale sensitive, | 235 // ASCII-specific tolower. The standard library's tolower is locale sensitive, |
235 // so we don't want to use it here. | 236 // so we don't want to use it here. |
236 template <class Char> inline Char ToLowerASCII(Char c) { | 237 template <class Char> inline Char ToLowerASCII(Char c) { |
237 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; | 238 return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; |
238 } | 239 } |
239 | 240 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
653 #elif defined(WCHAR_T_IS_UTF32) | 654 #elif defined(WCHAR_T_IS_UTF32) |
654 typedef uint32 Unsigned; | 655 typedef uint32 Unsigned; |
655 #endif | 656 #endif |
656 }; | 657 }; |
657 template<> | 658 template<> |
658 struct ToUnsigned<short> { | 659 struct ToUnsigned<short> { |
659 typedef unsigned short Unsigned; | 660 typedef unsigned short Unsigned; |
660 }; | 661 }; |
661 | 662 |
662 #endif // BASE_STRING_UTIL_H_ | 663 #endif // BASE_STRING_UTIL_H_ |
OLD | NEW |