| Index: base/strings/string_util.cc
|
| diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
|
| index e514ac1a6327416925969dd78ad5a730663ab2ea..0b1d085b4afd95df14989d7637ba7e726c61cf42 100644
|
| --- a/base/strings/string_util.cc
|
| +++ b/base/strings/string_util.cc
|
| @@ -324,7 +324,19 @@ bool ContainsOnlyChars(const StringPiece16& input,
|
| return input.find_first_not_of(characters) == StringPiece16::npos;
|
| }
|
|
|
| -} // namespace base
|
| +bool IsStringUTF8(const StringPiece& str) {
|
| + const char *src = str.data();
|
| + int32 src_len = static_cast<int32>(str.length());
|
| + int32 char_index = 0;
|
| +
|
| + while (char_index < src_len) {
|
| + int32 code_point;
|
| + CBU8_NEXT(src, char_index, src_len, code_point);
|
| + if (!IsValidCharacter(code_point))
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
|
|
| template<class STR>
|
| static bool DoIsStringASCII(const STR& str) {
|
| @@ -336,7 +348,7 @@ static bool DoIsStringASCII(const STR& str) {
|
| return true;
|
| }
|
|
|
| -bool IsStringASCII(const base::StringPiece& str) {
|
| +bool IsStringASCII(const StringPiece& str) {
|
| return DoIsStringASCII(str);
|
| }
|
|
|
| @@ -344,19 +356,7 @@ bool IsStringASCII(const base::string16& str) {
|
| return DoIsStringASCII(str);
|
| }
|
|
|
| -bool IsStringUTF8(const std::string& str) {
|
| - const char *src = str.data();
|
| - int32 src_len = static_cast<int32>(str.length());
|
| - int32 char_index = 0;
|
| -
|
| - while (char_index < src_len) {
|
| - int32 code_point;
|
| - CBU8_NEXT(src, char_index, src_len, code_point);
|
| - if (!base::IsValidCharacter(code_point))
|
| - return false;
|
| - }
|
| - return true;
|
| -}
|
| +} // namespace base
|
|
|
| template<typename Iter>
|
| static inline bool DoLowerCaseEqualsASCII(Iter a_begin,
|
|
|