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 #include "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <stdarg.h> | 10 #include <stdarg.h> |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 bool IsStringASCII(const string16& str) { | 399 bool IsStringASCII(const string16& str) { |
400 return DoIsStringASCII(str.data(), str.length()); | 400 return DoIsStringASCII(str.data(), str.length()); |
401 } | 401 } |
402 | 402 |
403 #if defined(WCHAR_T_IS_UTF32) | 403 #if defined(WCHAR_T_IS_UTF32) |
404 bool IsStringASCII(const std::wstring& str) { | 404 bool IsStringASCII(const std::wstring& str) { |
405 return DoIsStringASCII(str.data(), str.length()); | 405 return DoIsStringASCII(str.data(), str.length()); |
406 } | 406 } |
407 #endif | 407 #endif |
408 | 408 |
409 bool IsStringUTF8(const std::string& str) { | 409 bool IsStringUTF8(const StringPiece& str) { |
410 const char *src = str.data(); | 410 const char *src = str.data(); |
411 int32 src_len = static_cast<int32>(str.length()); | 411 int32 src_len = static_cast<int32>(str.length()); |
412 int32 char_index = 0; | 412 int32 char_index = 0; |
413 | 413 |
414 while (char_index < src_len) { | 414 while (char_index < src_len) { |
415 int32 code_point; | 415 int32 code_point; |
416 CBU8_NEXT(src, char_index, src_len, code_point); | 416 CBU8_NEXT(src, char_index, src_len, code_point); |
417 if (!IsValidCharacter(code_point)) | 417 if (!IsValidCharacter(code_point)) |
418 return false; | 418 return false; |
419 } | 419 } |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
949 } | 949 } |
950 | 950 |
951 } // namespace | 951 } // namespace |
952 | 952 |
953 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { | 953 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { |
954 return lcpyT<char>(dst, src, dst_size); | 954 return lcpyT<char>(dst, src, dst_size); |
955 } | 955 } |
956 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 956 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
957 return lcpyT<wchar_t>(dst, src, dst_size); | 957 return lcpyT<wchar_t>(dst, src, dst_size); |
958 } | 958 } |
OLD | NEW |