From 55150c49fc13a00944360b803cec2b6598585b54 Mon Sep 17 00:00:00 2001 From: "kuchhal@chromium.org" Date: Thu, 26 Feb 2009 21:27:55 +0000 Subject: Revert "ASCII <-> UTF16 conversion functions. These are just copies of WideToASCII and" Review URL: http://codereview.chromium.org/28217 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10512 0039d316-1c4b-4281-b951-d872f2087c98 --- base/string_util.cc | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'base/string_util.cc') diff --git a/base/string_util.cc b/base/string_util.cc index d84fadb..4ba8c4b 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -450,16 +450,6 @@ std::wstring ASCIIToWide(const std::string& ascii) { return std::wstring(ascii.begin(), ascii.end()); } -std::string UTF16ToASCII(const string16& utf16) { - DCHECK(IsStringASCII(utf16)); - return std::string(utf16.begin(), utf16.end()); -} - -string16 ASCIIToUTF16(const std::string& ascii) { - DCHECK(IsStringASCII(ascii)); - return string16(ascii.begin(), ascii.end()); -} - // Latin1 is just the low range of Unicode, so we can copy directly to convert. bool WideToLatin1(const std::wstring& wide, std::string* latin1) { std::string output; @@ -482,28 +472,20 @@ bool IsString8Bit(const std::wstring& str) { return true; } -template -static bool DoIsStringASCII(const STR& str) { +bool IsStringASCII(const std::wstring& str) { for (size_t i = 0; i < str.length(); i++) { - typename ToUnsigned::Unsigned c = str[i]; - if (c > 0x7F) + if (str[i] > 0x7F) return false; } return true; } -bool IsStringASCII(const std::wstring& str) { - return DoIsStringASCII(str); -} - -#if !defined(WCHAR_T_IS_UTF16) -bool IsStringASCII(const string16& str) { - return DoIsStringASCII(str); -} -#endif - bool IsStringASCII(const std::string& str) { - return DoIsStringASCII(str); + for (size_t i = 0; i < str.length(); i++) { + if (static_cast(str[i]) > 0x7F) + return false; + } + return true; } // Helper functions that determine whether the given character begins a -- cgit v1.1