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

Unified Diff: third_party/WebKit/Source/platform/exported/WebString.cpp

Issue 2629573002: Allow WebString.utf8() to take UTF8ConversionMode (Closed)
Patch Set: fix Created 3 years, 11 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: third_party/WebKit/Source/platform/exported/WebString.cpp
diff --git a/third_party/WebKit/Source/platform/exported/WebString.cpp b/third_party/WebKit/Source/platform/exported/WebString.cpp
index 5ff32e9381c8c28c8495f38d2ef4ed4e45382cee..b2dbb187e638e17a3b7a52242cc7d57469cb19d7 100644
--- a/third_party/WebKit/Source/platform/exported/WebString.cpp
+++ b/third_party/WebKit/Source/platform/exported/WebString.cpp
@@ -38,6 +38,18 @@
#include "wtf/text/StringView.h"
#include "wtf/text/WTFString.h"
+#define STATIC_ASSERT_ENUM(a, b) \
+ static_assert(static_cast<int>(a) == static_cast<int>(b), \
+ "mismatching enums: " #a)
+
+STATIC_ASSERT_ENUM(WTF::LenientUTF8Conversion,
+ blink::WebString::LenientUTF8Conversion);
+STATIC_ASSERT_ENUM(WTF::StrictUTF8Conversion,
+ blink::WebString::StrictUTF8Conversion);
+STATIC_ASSERT_ENUM(
+ WTF::StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD,
+ blink::WebString::StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD);
+
namespace blink {
void WebString::reset() {
@@ -68,7 +80,7 @@ const WebUChar* WebString::data16() const {
return !m_private.isNull() && !is8Bit() ? m_private->characters16() : 0;
}
-std::string WebString::utf8() const {
+std::string WebString::utf8(UTF8ConversionMode mode) const {
StringUTF8Adaptor utf8(m_private.get());
return std::string(utf8.data(), utf8.length());
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/text/StringUTF8Adaptor.h » ('j') | third_party/WebKit/public/platform/WebString.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698