diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-24 20:48:16 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-24 20:48:16 +0000 |
commit | c5884ad724ec7303e0cac77622607cf0160b5bd0 (patch) | |
tree | ebda5cf20a164f4b2a93f26bd92f606a673bec32 /base | |
parent | 5f0cebb46d66ef0a1996594d0846c0067a8cf475 (diff) | |
download | chromium_src-c5884ad724ec7303e0cac77622607cf0160b5bd0.zip chromium_src-c5884ad724ec7303e0cac77622607cf0160b5bd0.tar.gz chromium_src-c5884ad724ec7303e0cac77622607cf0160b5bd0.tar.bz2 |
Move WideToASCII to the base namespace.
I accidentally changed some callers to use "base::" for this call. Since the
plan is to move this to the base namespace eventually, I went ahead and added
it with a "using" (to keep the non-converted code compiling) rather than revert
my other changes.
TBR=sky
Review URL: https://codereview.chromium.org/12330103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@184353 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/string_util.cc | 8 | ||||
-rw-r--r-- | base/string_util.h | 6 |
2 files changed, 12 insertions, 2 deletions
diff --git a/base/string_util.cc b/base/string_util.cc index 91a1c4c..efc15f3 100644 --- a/base/string_util.cc +++ b/base/string_util.cc @@ -415,16 +415,20 @@ bool ContainsOnlyChars(const std::string& input, return ContainsOnlyCharsT(input, characters); } +namespace base { + std::string WideToASCII(const std::wstring& wide) { - DCHECK(IsStringASCII(wide)) << wide; + DCHECK(IsStringASCII(wide)) << WideToUTF8(wide); return std::string(wide.begin(), wide.end()); } std::string UTF16ToASCII(const string16& utf16) { - DCHECK(IsStringASCII(utf16)) << utf16; + DCHECK(IsStringASCII(utf16)) << UTF16ToUTF8(utf16); return std::string(utf16.begin(), utf16.end()); } +} // namespace base + // 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; diff --git a/base/string_util.h b/base/string_util.h index 367eaa8..b9301c6 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -275,8 +275,14 @@ BASE_EXPORT bool ContainsOnlyChars(const std::string& input, // Converts to 7-bit ASCII by truncating. The result must be known to be ASCII // beforehand. +namespace base { BASE_EXPORT std::string WideToASCII(const std::wstring& wide); BASE_EXPORT std::string UTF16ToASCII(const string16& utf16); +} // namespace base +// TODO(brettw) convert this entier file to using the base namespace and remove +// this using. +using base::WideToASCII; +using base::UTF16ToASCII; // Converts the given wide string to the corresponding Latin1. This will fail // (return false) if any characters are more than 255. |