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

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

Issue 2629573002: Allow WebString.utf8() to take UTF8ConversionMode (Closed)
Patch Set: comment 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..a41e1b034d51a0a4c6547da1b6ab973eac2ff7aa 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::UTF8ConversionMode::kLenient);
+STATIC_ASSERT_ENUM(WTF::StrictUTF8Conversion,
+ blink::WebString::UTF8ConversionMode::kStrict);
+STATIC_ASSERT_ENUM(
+ WTF::StrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD,
+ blink::WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD);
+
namespace blink {
void WebString::reset() {
@@ -68,8 +80,9 @@ const WebUChar* WebString::data16() const {
return !m_private.isNull() && !is8Bit() ? m_private->characters16() : 0;
}
-std::string WebString::utf8() const {
- StringUTF8Adaptor utf8(m_private.get());
+std::string WebString::utf8(UTF8ConversionMode mode) const {
+ StringUTF8Adaptor utf8(m_private.get(),
+ static_cast<WTF::UTF8ConversionMode>(mode));
return std::string(utf8.data(), utf8.length());
}
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/exported/WebStringTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698