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

Unified Diff: base/strings/string_util.cc

Issue 1125773004: Pull in ASCII<->UTF16 from Chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/strings/string_util.h ('k') | base/strings/utf_string_conversions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/string_util.cc
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fa985c0ad7e25afd040b0436fdcb05703978c877
--- /dev/null
+++ b/base/strings/string_util.cc
@@ -0,0 +1,23 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/strings/string_util.h"
+
+namespace base {
+
+bool IsStringASCII(const StringPiece& str) {
+ for (size_t i = 0; i < str.length(); ++i)
scottmg 2015/05/04 23:15:33 The Chromium implementation of these is surprising
+ if (str.data()[i] >= 0x80)
+ return false;
+ return true;
+}
+
+bool IsStringASCII(const StringPiece16& str) {
+ for (size_t i = 0; i < str.length(); ++i)
+ if (str.data()[i] >= 0x80)
+ return false;
+ return true;
+}
+
+} // namespace base
« no previous file with comments | « base/strings/string_util.h ('k') | base/strings/utf_string_conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698