Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <ctype.h> | 9 #include <ctype.h> |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 } | 468 } |
| 469 | 469 |
| 470 bool IsStringUTF8(const std::string& str) { | 470 bool IsStringUTF8(const std::string& str) { |
| 471 const char *src = str.data(); | 471 const char *src = str.data(); |
| 472 int32 src_len = static_cast<int32>(str.length()); | 472 int32 src_len = static_cast<int32>(str.length()); |
| 473 int32 char_index = 0; | 473 int32 char_index = 0; |
| 474 | 474 |
| 475 while (char_index < src_len) { | 475 while (char_index < src_len) { |
| 476 int32 code_point; | 476 int32 code_point; |
| 477 CBU8_NEXT(src, char_index, src_len, code_point); | 477 CBU8_NEXT(src, char_index, src_len, code_point); |
| 478 if (!base::IsValidCharacter(code_point)) | 478 if (!base::IsValidCharacter(code_point)) { |
| 479 return false; | 479 for (size_t i = 0; i < str.length(); ++i) { |
|
Mark Mentovai
2012/05/08 20:19:41
Dump the debugging code.
Robert Sesek
2012/05/15 16:57:51
Done.
| |
| 480 printf("0x%x ", str[i]); | |
| 481 } | |
| 482 printf("\n"); | |
| 483 LOG(INFO) << "STRING = <<<" << str << ">>>"; | |
| 484 LOG(INFO) << "**** char_index = " << char_index << " // " << code_point; | |
| 485 return false; | |
| 486 } | |
| 480 } | 487 } |
| 481 return true; | 488 return true; |
| 482 } | 489 } |
| 483 | 490 |
| 484 template<typename Iter> | 491 template<typename Iter> |
| 485 static inline bool DoLowerCaseEqualsASCII(Iter a_begin, | 492 static inline bool DoLowerCaseEqualsASCII(Iter a_begin, |
| 486 Iter a_end, | 493 Iter a_end, |
| 487 const char* b) { | 494 const char* b) { |
| 488 for (Iter it = a_begin; it != a_end; ++it, ++b) { | 495 for (Iter it = a_begin; it != a_end; ++it, ++b) { |
| 489 if (!*b || base::ToLowerASCII(*it) != *b) | 496 if (!*b || base::ToLowerASCII(*it) != *b) |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1046 } | 1053 } |
| 1047 | 1054 |
| 1048 } // namespace | 1055 } // namespace |
| 1049 | 1056 |
| 1050 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { | 1057 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { |
| 1051 return lcpyT<char>(dst, src, dst_size); | 1058 return lcpyT<char>(dst, src, dst_size); |
| 1052 } | 1059 } |
| 1053 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 1060 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
| 1054 return lcpyT<wchar_t>(dst, src, dst_size); | 1061 return lcpyT<wchar_t>(dst, src, dst_size); |
| 1055 } | 1062 } |
| OLD | NEW |