summaryrefslogtreecommitdiffstats
path: root/base/strings
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 23:55:43 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-17 23:55:43 +0000
commitbd6fc2fb1af851ac7e2f4a3e08ad3a92ab6ba4af (patch)
treedb093d44a2b6964ae5b54b140bdef71a8b7a337d /base/strings
parentbec9fd9900ed7fe4ed3fe5b3d9f56ec4ba1fe56b (diff)
downloadchromium_src-bd6fc2fb1af851ac7e2f4a3e08ad3a92ab6ba4af.zip
chromium_src-bd6fc2fb1af851ac7e2f4a3e08ad3a92ab6ba4af.tar.gz
chromium_src-bd6fc2fb1af851ac7e2f4a3e08ad3a92ab6ba4af.tar.bz2
Revert 257524 "Move IsStringASCII/UTF8 to base namespace."
> Move IsStringASCII/UTF8 to base namespace. > > Use StringPiece for IsStringUTF8. > > TBR=sky > > Review URL: https://codereview.chromium.org/196793010 TBR=brettw@chromium.org Review URL: https://codereview.chromium.org/198163004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/strings')
-rw-r--r--base/strings/string_util.cc30
-rw-r--r--base/strings/string_util.h26
2 files changed, 28 insertions, 28 deletions
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index 0b1d085..e514ac1 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -324,19 +324,7 @@ bool ContainsOnlyChars(const StringPiece16& input,
return input.find_first_not_of(characters) == StringPiece16::npos;
}
-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;
-}
+} // namespace base
template<class STR>
static bool DoIsStringASCII(const STR& str) {
@@ -348,7 +336,7 @@ static bool DoIsStringASCII(const STR& str) {
return true;
}
-bool IsStringASCII(const StringPiece& str) {
+bool IsStringASCII(const base::StringPiece& str) {
return DoIsStringASCII(str);
}
@@ -356,7 +344,19 @@ bool IsStringASCII(const base::string16& str) {
return DoIsStringASCII(str);
}
-} // namespace base
+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;
+}
template<typename Iter>
static inline bool DoLowerCaseEqualsASCII(Iter a_begin,
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index dd87d5b..473deae 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -234,6 +234,16 @@ BASE_EXPORT bool ContainsOnlyChars(const StringPiece& input,
BASE_EXPORT bool ContainsOnlyChars(const StringPiece16& input,
const StringPiece16& characters);
+} // namespace base
+
+#if defined(OS_WIN)
+#include "base/strings/string_util_win.h"
+#elif defined(OS_POSIX)
+#include "base/strings/string_util_posix.h"
+#else
+#error Define string operations appropriately for your platform
+#endif
+
// Returns true if the specified string matches the criteria. How can a wide
// string be 8-bit or UTF8? It contains only characters that are < 256 (in the
// first case) or characters that use only 8-bits and whose 8-bit
@@ -245,19 +255,9 @@ BASE_EXPORT bool ContainsOnlyChars(const StringPiece16& input,
// to have the maximum 'discriminating' power from other encodings. If
// there's a use case for just checking the structural validity, we have to
// add a new function for that.
-BASE_EXPORT bool IsStringUTF8(const StringPiece& str);
-BASE_EXPORT bool IsStringASCII(const StringPiece& str);
-BASE_EXPORT bool IsStringASCII(const string16& str);
-
-} // namespace base
-
-#if defined(OS_WIN)
-#include "base/strings/string_util_win.h"
-#elif defined(OS_POSIX)
-#include "base/strings/string_util_posix.h"
-#else
-#error Define string operations appropriately for your platform
-#endif
+BASE_EXPORT bool IsStringUTF8(const std::string& str);
+BASE_EXPORT bool IsStringASCII(const base::StringPiece& str);
+BASE_EXPORT bool IsStringASCII(const base::string16& str);
// Converts the elements of the given string. This version uses a pointer to
// clearly differentiate it from the non-pointer variant.