Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: base/string_util.h

Issue 4268: IsStringUTF8 unittest and enforcing UTF-8 in JSON deserialization (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/json_reader_unittest.cc ('k') | base/string_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/json_reader_unittest.cc ('k') | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698