| Index: base/strings/utf_string_conversions.cc
|
| diff --git a/base/strings/utf_string_conversions.cc b/base/strings/utf_string_conversions.cc
|
| index 1480d48086fed618ffbcc95cf918d8a0c1ebcb7e..b6cf6ff9b101446d026484df7e1c569fcec434bf 100644
|
| --- a/base/strings/utf_string_conversions.cc
|
| +++ b/base/strings/utf_string_conversions.cc
|
| @@ -73,7 +73,7 @@ bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output) {
|
| }
|
| }
|
|
|
| -std::wstring UTF8ToWide(const StringPiece& utf8) {
|
| +std::wstring UTF8ToWide(StringPiece utf8) {
|
| if (IsStringASCII(utf8)) {
|
| return std::wstring(utf8.begin(), utf8.end());
|
| }
|
| @@ -153,7 +153,7 @@ bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
|
| }
|
| }
|
|
|
| -string16 UTF8ToUTF16(const StringPiece& utf8) {
|
| +string16 UTF8ToUTF16(StringPiece utf8) {
|
| if (IsStringASCII(utf8)) {
|
| return string16(utf8.begin(), utf8.end());
|
| }
|
| @@ -176,7 +176,7 @@ bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) {
|
| }
|
| }
|
|
|
| -std::string UTF16ToUTF8(const string16& utf16) {
|
| +std::string UTF16ToUTF8(StringPiece16 utf16) {
|
| if (IsStringASCII(utf16)) {
|
| return std::string(utf16.begin(), utf16.end());
|
| }
|
| @@ -195,7 +195,7 @@ bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
|
| return UTF8ToWide(src, src_len, output);
|
| }
|
|
|
| -string16 UTF8ToUTF16(const StringPiece& utf8) {
|
| +string16 UTF8ToUTF16(StringPiece utf8) {
|
| return UTF8ToWide(utf8);
|
| }
|
|
|
| @@ -203,18 +203,24 @@ bool UTF16ToUTF8(const char16* src, size_t src_len, std::string* output) {
|
| return WideToUTF8(src, src_len, output);
|
| }
|
|
|
| -std::string UTF16ToUTF8(const string16& utf16) {
|
| - return WideToUTF8(utf16);
|
| +std::string UTF16ToUTF8(StringPiece16 utf16) {
|
| + if (IsStringASCII(utf16))
|
| + return std::string(utf16.data(), utf16.data() + utf16.length());
|
| +
|
| + std::string ret;
|
| + PrepareForUTF8Output(utf16.data(), utf16.length(), &ret);
|
| + ConvertUnicode(utf16.data(), utf16.length(), &ret);
|
| + return ret;
|
| }
|
|
|
| #endif
|
|
|
| -string16 ASCIIToUTF16(const StringPiece& ascii) {
|
| +string16 ASCIIToUTF16(StringPiece ascii) {
|
| DCHECK(IsStringASCII(ascii)) << ascii;
|
| return string16(ascii.begin(), ascii.end());
|
| }
|
|
|
| -std::string UTF16ToASCII(const string16& utf16) {
|
| +std::string UTF16ToASCII(StringPiece16 utf16) {
|
| DCHECK(IsStringASCII(utf16)) << UTF16ToUTF8(utf16);
|
| return std::string(utf16.begin(), utf16.end());
|
| }
|
|
|