summaryrefslogtreecommitdiffstats
path: root/webkit/glue/glue_util.h
diff options
context:
space:
mode:
authorbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 22:38:42 +0000
committerbrettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-14 22:38:42 +0000
commit24729272479b4f42bb137d8e3e50c445cd72e30e (patch)
treea1b3f0ca4014e4c76995452420a18b05c9bbb186 /webkit/glue/glue_util.h
parent1a84e8ebf01c44c3af3810e62b13b25174cf4e03 (diff)
downloadchromium_src-24729272479b4f42bb137d8e3e50c445cd72e30e.zip
chromium_src-24729272479b4f42bb137d8e3e50c445cd72e30e.tar.gz
chromium_src-24729272479b4f42bb137d8e3e50c445cd72e30e.tar.bz2
Fix a bug where if we converted a std::string into a WebCore::String,
the encoding will be incorrect. We assume std::string is UTF-8, but WebCore assume it's Latin-1 when you use the 8-bit constructor. Review URL: http://codereview.chromium.org/7266 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3375 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/glue_util.h')
-rw-r--r--webkit/glue/glue_util.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h
index c8303eb..91fa16a 100644
--- a/webkit/glue/glue_util.h
+++ b/webkit/glue/glue_util.h
@@ -11,20 +11,30 @@
#include "googleurl/src/gurl.h"
namespace WebCore {
- class CString;
- class KURL;
- class String;
+class CString;
+class KURL;
+class String;
}
namespace webkit_glue {
+// WebCore::CString <-> std::string. All characters are 8-bit and are preserved
+// unchanged.
std::string CStringToStdString(const WebCore::CString& str);
WebCore::CString StdStringToCString(const std::string& str);
+
+// WebCore::String <-> std::wstring. We assume that the WebCore::String is in
+// UTF-16, and will either copy to a UTF-16 std::wstring (on Windows) or convert
+// to a UTF-32 one on Linux and Mac.
std::wstring StringToStdWString(const WebCore::String& str);
+WebCore::String StdWStringToString(const std::wstring& str);
+
+// WebCore::String -> string16. This is a direct copy of UTF-16 characters.
string16 StringToString16(const WebCore::String& str);
-std::string StringToStdString(const WebCore::String& str);
-WebCore::String StdWStringToString(const std::wstring& str);
+// WebCore::String <-> std::string. We assume the WebCore::String is UTF-16 and
+// the std::string is UTF-8, and convert as necessary.
+std::string StringToStdString(const WebCore::String& str);
WebCore::String StdStringToString(const std::string& str);
GURL KURLToGURL(const WebCore::KURL& url);