summaryrefslogtreecommitdiffstats
path: root/base/utf_string_conversions.cc
diff options
context:
space:
mode:
authorsuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 02:40:46 +0000
committersuzhe@google.com <suzhe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-28 02:40:46 +0000
commit39a749c1cc998edcd66edfc3ffc9004710825f46 (patch)
tree370b1a18564e743cfbfc16beb4d0053437064486 /base/utf_string_conversions.cc
parent911696b92b1b5a666e59433b8b64303a2f4eae62 (diff)
downloadchromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.zip
chromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.tar.gz
chromium_src-39a749c1cc998edcd66edfc3ffc9004710825f46.tar.bz2
Change UTF8ToUTF16 to accept const StringPiece&.
BUG=70936 TEST=All unit tests should pass. Review URL: http://codereview.chromium.org/6317016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/utf_string_conversions.cc')
-rw-r--r--base/utf_string_conversions.cc18
1 files changed, 4 insertions, 14 deletions
diff --git a/base/utf_string_conversions.cc b/base/utf_string_conversions.cc
index 41a70db..7b73696 100644
--- a/base/utf_string_conversions.cc
+++ b/base/utf_string_conversions.cc
@@ -133,7 +133,7 @@ bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
return ConvertUnicode(src, src_len, output);
}
-string16 UTF8ToUTF16(const std::string& utf8) {
+string16 UTF8ToUTF16(const base::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.
@@ -161,7 +161,7 @@ bool UTF8ToUTF16(const char* src, size_t src_len, string16* output) {
return UTF8ToWide(src, src_len, output);
}
-string16 UTF8ToUTF16(const std::string& utf8) {
+string16 UTF8ToUTF16(const base::StringPiece& utf8) {
return UTF8ToWide(utf8);
}
@@ -175,22 +175,12 @@ std::string UTF16ToUTF8(const string16& utf16) {
#endif
-std::wstring ASCIIToWide(const char* ascii) {
- DCHECK(IsStringASCII(ascii)) << ascii;
- return std::wstring(ascii, &ascii[strlen(ascii)]);
-}
-
-std::wstring ASCIIToWide(const std::string& ascii) {
+std::wstring ASCIIToWide(const base::StringPiece& ascii) {
DCHECK(IsStringASCII(ascii)) << ascii;
return std::wstring(ascii.begin(), ascii.end());
}
-string16 ASCIIToUTF16(const char* ascii) {
- DCHECK(IsStringASCII(ascii)) << ascii;
- return string16(ascii, &ascii[strlen(ascii)]);
-}
-
-string16 ASCIIToUTF16(const std::string& ascii) {
+string16 ASCIIToUTF16(const base::StringPiece& ascii) {
DCHECK(IsStringASCII(ascii)) << ascii;
return string16(ascii.begin(), ascii.end());
}