diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 01:43:15 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-10 01:43:15 +0000 |
commit | 2500a0f7c4ac54a55d621069dc044ddc6702a518 (patch) | |
tree | 960a571bb2b49c9005fd152138e4398df9072854 /base/utf_string_conversions.cc | |
parent | 0d435eae98fbe4f8055215a7aa6c483b07b7fa03 (diff) | |
download | chromium_src-2500a0f7c4ac54a55d621069dc044ddc6702a518.zip chromium_src-2500a0f7c4ac54a55d621069dc044ddc6702a518.tar.gz chromium_src-2500a0f7c4ac54a55d621069dc044ddc6702a518.tar.bz2 |
Clean up recent string conversion function changes, part 1: Remove unnecessary code. Thanks to a change in escape.cc I can basically revert the ICU conversions back to what they used to be; I can also get rid of half the conversions immediately since they aren't used.
This does not split out the "adjust" versions of the UTF conversions into their own header/implementation; that's coming in the next patch.
BUG=4010
TEST=none
Review URL: http://codereview.chromium.org/380007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/utf_string_conversions.cc')
-rw-r--r-- | base/utf_string_conversions.cc | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/base/utf_string_conversions.cc b/base/utf_string_conversions.cc index ffff50a..ee52f47 100644 --- a/base/utf_string_conversions.cc +++ b/base/utf_string_conversions.cc @@ -221,22 +221,16 @@ void PrepareForUTF16Or32Output(const char* src, // UTF-8 <-> Wide -------------------------------------------------------------- -bool WideToUTF8AndAdjustOffset(const wchar_t* src, - size_t src_len, - std::string* output, - size_t* offset_for_adjustment) { +bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output) { PrepareForUTF8Output(src, src_len, output); - return ConvertUnicode<wchar_t, std::string>(src, src_len, output, - offset_for_adjustment); + return ConvertUnicode<wchar_t, std::string>(src, src_len, output, NULL); } -std::string WideToUTF8AndAdjustOffset(const std::wstring& wide, - size_t* offset_for_adjustment) { +std::string WideToUTF8(const std::wstring& wide) { 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. - WideToUTF8AndAdjustOffset(wide.data(), wide.length(), &ret, - offset_for_adjustment); + WideToUTF8(wide.data(), wide.length(), &ret); return ret; } @@ -262,20 +256,12 @@ std::wstring UTF8ToWideAndAdjustOffset(const base::StringPiece& utf8, #if defined(WCHAR_T_IS_UTF16) // When wide == UTF-16, then conversions are a NOP. -bool WideToUTF16AndAdjustOffset(const wchar_t* src, - size_t src_len, - string16* output, - size_t* offset_for_adjustment) { +bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output) { output->assign(src, src_len); - if (offset_for_adjustment && (*offset_for_adjustment >= src_len)) - *offset_for_adjustment = string16::npos; return true; } -string16 WideToUTF16AndAdjustOffset(const std::wstring& wide, - size_t* offset_for_adjustment) { - if (offset_for_adjustment && (*offset_for_adjustment >= wide.length())) - *offset_for_adjustment = string16::npos; +string16 WideToUTF16(const std::wstring& wide) { return wide; } @@ -298,23 +284,17 @@ std::wstring UTF16ToWideAndAdjustOffset(const string16& utf16, #elif defined(WCHAR_T_IS_UTF32) -bool WideToUTF16AndAdjustOffset(const wchar_t* src, - size_t src_len, - string16* output, - size_t* offset_for_adjustment) { +bool WideToUTF16(const wchar_t* src, size_t src_len, string16* output) { output->clear(); // Assume that normally we won't have any non-BMP characters so the counts // will be the same. output->reserve(src_len); - return ConvertUnicode<wchar_t, string16>(src, src_len, output, - offset_for_adjustment); + return ConvertUnicode<wchar_t, string16>(src, src_len, output, NULL); } -string16 WideToUTF16AndAdjustOffset(const std::wstring& wide, - size_t* offset_for_adjustment) { +string16 WideToUTF16(const std::wstring& wide) { string16 ret; - WideToUTF16AndAdjustOffset(wide.data(), wide.length(), &ret, - offset_for_adjustment); + WideToUTF16(wide.data(), wide.length(), &ret); return ret; } |