Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(664)

Unified Diff: Source/core/platform/chromium/support/WebString.cpp

Issue 23456013: Expose latin1 methods in WebString (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/platform/chromium/support/WebString.cpp
diff --git a/Source/core/platform/chromium/support/WebString.cpp b/Source/core/platform/chromium/support/WebString.cpp
index 4b5dd6b5150a70ab631a9f766e4d8746c1b78cb3..be8151cf06fb2b462d1e23aa994cbe04942e20b8 100644
--- a/Source/core/platform/chromium/support/WebString.cpp
+++ b/Source/core/platform/chromium/support/WebString.cpp
@@ -96,6 +96,22 @@ WebString WebString::fromUTF8(const char* data)
return WTF::String::fromUTF8(data);
}
+std::string WebString::latin1() const
+{
+ String string(m_private.get());
+
+ if (string.is8Bit())
abarth-chromium 2013/09/03 15:46:40 You need to handle the isEmpty() case as well. Yo
davidben 2013/09/03 17:58:25 Done.
+ return std::string(reinterpret_cast<const char*>(string.characters8()), string.length());
+
+ WebCString latin1 = string.latin1();
+ return std::string(latin1.data(), latin1.length());
+}
+
+WebString WebString::fromLatin1(const char* data, size_t length)
+{
+ return String(data, length);
+}
+
bool WebString::equals(const WebString& s) const
{
return equal(m_private.get(), s.m_private.get());

Powered by Google App Engine
This is Rietveld 408576698