diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 13:19:24 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-19 13:19:24 +0000 |
commit | 4bdaceb429c7cd6a3a2a8bc692f418969c24ff28 (patch) | |
tree | e399572c17bb4ed5de86bd702ea28a041e40b9b0 /base/sys_string_conversions_linux.cc | |
parent | 1e3f8396c6f205b2be2a102d4fbca870638e7f6b (diff) | |
download | chromium_src-4bdaceb429c7cd6a3a2a8bc692f418969c24ff28.zip chromium_src-4bdaceb429c7cd6a3a2a8bc692f418969c24ff28.tar.gz chromium_src-4bdaceb429c7cd6a3a2a8bc692f418969c24ff28.tar.bz2 |
Move the system string conversion functions from std::string to StringPiece. We often work with char* in the system layer, so this should save extra copying.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/sys_string_conversions_linux.cc')
-rw-r--r-- | base/sys_string_conversions_linux.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/base/sys_string_conversions_linux.cc b/base/sys_string_conversions_linux.cc index 639b402..9547ef9 100644 --- a/base/sys_string_conversions_linux.cc +++ b/base/sys_string_conversions_linux.cc @@ -29,6 +29,7 @@ #include "base/sys_string_conversions.h" +#include "base/string_piece.h" #include "base/string_util.h" namespace base { @@ -38,10 +39,12 @@ std::string SysWideToUTF8(const std::wstring& wide) { // than our ICU, but this will do for now. return WideToUTF8(wide); } -std::wstring SysUTF8ToWide(const std::string& utf8) { +std::wstring SysUTF8ToWide(StringPiece utf8) { // In theory this should be using the system-provided conversion rather // than our ICU, but this will do for now. - return UTF8ToWide(utf8); + std::wstring out; + UTF8ToWide(utf8.data(), utf8.size(), &out); + return out; } std::string SysWideToNativeMB(const std::wstring& wide) { @@ -49,7 +52,7 @@ std::string SysWideToNativeMB(const std::wstring& wide) { return SysWideToUTF8(wide); } -std::wstring SysNativeMBToWide(const std::string& native_mb) { +std::wstring SysNativeMBToWide(StringPiece native_mb) { // TODO(evanm): we can't assume Linux is UTF-8. return SysUTF8ToWide(native_mb); } |