diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 15:29:49 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-07 15:29:49 +0000 |
commit | 6b27db809e959efaf7183ea2de64c6ab3947ef3d (patch) | |
tree | ed2ed10f826f6eb40884231ee0c98d86afef44a7 /base/string_util.h | |
parent | 65b1094478e054ef1f924d3681f8d34ec88d9fcf (diff) | |
download | chromium_src-6b27db809e959efaf7183ea2de64c6ab3947ef3d.zip chromium_src-6b27db809e959efaf7183ea2de64c6ab3947ef3d.tar.gz chromium_src-6b27db809e959efaf7183ea2de64c6ab3947ef3d.tar.bz2 |
Remove the old NativeMB functions from string util, and use the new ones in sys_strings.h. I also removed duplicated code from the sandbox that can now use this, and fixed one case in the bug reporter that should not have been using the native multibyte encoding.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r-- | base/string_util.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/base/string_util.h b/base/string_util.h index d47d5f2..129f124 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -155,21 +155,17 @@ std::wstring CollapseWhitespace(const std::wstring& text, std::string WideToASCII(const std::wstring& wide); std::wstring ASCIIToWide(const std::string& ascii); -// These convert between UTF8 and UTF16 strings. They are potentially slow, -// so avoid unnecessary conversions. Most things should be in UTF16. +// These convert between UTF8 and UTF16 strings. They are potentially slow, so +// avoid unnecessary conversions. Most things should be in wide. The low-level +// versions return a boolean indicating whether the conversion was 100% valid. +// In this case, it will still do the best it can and put the result in the +// output buffer. The versions that return strings ignore this error and just +// return the best conversion possible. +bool WideToUTF8(const wchar_t* src, size_t src_len, std::string* output); std::string WideToUTF8(const std::wstring& wide); +bool UTF8ToWide(const char* src, size_t src_len, std::wstring* output); std::wstring UTF8ToWide(const std::string& utf8); -// Converts between wide strings and whatever the native multibyte encoding -// is. The native multibyte encoding on English machines will often Latin-1, -// but could be ShiftJIS or even UTF-8, among others. -// -// These functions can be dangerous. Do not use unless you are sure you are -// giving them to/getting them from somebody who expects the current platform -// 8-bit encoding. -std::string WideToNativeMB(const std::wstring& wide); -std::wstring NativeMBToWide(const std::string& native_mb); - // Defines the error handling modes of WideToCodepage and CodepageToWide. class OnStringUtilConversionError { public: |