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

Unified Diff: base/strings/utf_string_conversions.cc

Issue 109863003: Use StringPiece for UTF string conversions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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/utf_string_conversions.h ('k') | chrome/test/chromedriver/chrome/zip_reader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/strings/utf_string_conversions.cc
diff --git a/base/strings/utf_string_conversions.cc b/base/strings/utf_string_conversions.cc
index c3ea4f253e5b5c68bc6c1795bc354178fcda3382..0256f8ac984d139f90085716a2e8607eaf526e69 100644
--- a/base/strings/utf_string_conversions.cc
+++ b/base/strings/utf_string_conversions.cc
@@ -125,45 +125,45 @@ std::wstring UTF16ToWide(const string16& utf16) {
#if defined(WCHAR_T_IS_UTF32)
-bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
- PrepareForUTF16Or32Output(src, src_len, output);
- return ConvertUnicode(src, src_len, output);
+bool UTF8ToUTF16(const StringPiece& utf8, string16* output) {
+ PrepareForUTF16Or32Output(utf8.data(), utf8.size(), output);
+ return ConvertUnicode(utf8.data(), utf8.size(), output);
}
string16 UTF8ToUTF16(const StringPiece& utf8) {
string16 ret;
// Ignore the success flag of this call, it will do the best it can for
// invalid input, which is what we want here.
- UTF8ToUTF16(utf8.data(), utf8.length(), &ret);
+ UTF8ToUTF16(utf8, &ret);
return ret;
}
-bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) {
- PrepareForUTF8Output(src, src_len, output);
- return ConvertUnicode(src, src_len, output);
+bool UTF16ToUTF8(const StringPiece16& utf16, std::string* output) {
+ PrepareForUTF8Output(utf16.data(), utf16.length(), output);
+ return ConvertUnicode(utf16.data(), utf16.length(), output);
}
std::string UTF16ToUTF8(const string16& utf16) {
std::string ret;
// Ignore the success flag of this call, it will do the best it can for
// invalid input, which is what we want here.
- UTF16ToUTF8(utf16.data(), utf16.length(), &ret);
+ UTF16ToUTF8(utf16, &ret);
return ret;
}
#elif defined(WCHAR_T_IS_UTF16)
// Easy case since we can use the "wide" versions we already wrote above.
-bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
- return UTF8ToWide(src, src_len, output);
+bool UTF8ToUTF16(const StringPiece& utf8, string16* output) {
+ return UTF8ToWide(utf8.data(), utf8.size(), output);
}
string16 UTF8ToUTF16(const StringPiece& utf8) {
return UTF8ToWide(utf8);
}
-bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) {
- return WideToUTF8(src, src_len, output);
+bool UTF16ToUTF8(const StringPiece16& utf16, std::string* output) {
+ return WideToUTF8(utf16.data(), utf16.size(), output);
}
std::string UTF16ToUTF8(const string16& utf16) {
« no previous file with comments | « base/strings/utf_string_conversions.h ('k') | chrome/test/chromedriver/chrome/zip_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698