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

Unified Diff: base/strings/string_util.cc

Issue 2201763002: Switch on use_new_wrapper_types mode for content/common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
Index: base/strings/string_util.cc
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index cb668ed7fff4f60f76291a0a19d478fb9faaacd5..e8f1ac724e3a88e6fe9e28f3598521edb61dfa11 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -963,6 +963,21 @@ string16 ReplaceStringPlaceholders(const string16& format_string,
return result;
}
+string16 Uint8VectorToString16(const std::vector<uint8_t>& input) {
+ if (input.empty())
+ return string16();
+
+ return string16(reinterpret_cast<const char16*>(&input.front()),
+ input.size() / sizeof(char16));
+}
+
+std::vector<uint8_t> String16ToUint8Vector(const string16& input) {
+ std::vector<uint8_t> result(input.size() * sizeof(char16));
+ if (!input.empty())
+ memcpy(&result.front(), input.c_str(), input.size() * sizeof(char16));
+ return result;
+}
+
// The following code is compatible with the OpenBSD lcpy interface. See:
// http://www.gratisoft.us/todd/papers/strlcpy.html
// ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/{wcs,str}lcpy.c

Powered by Google App Engine
This is Rietveld 408576698