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

Unified Diff: third_party/WebKit/Source/wtf/text/TextEncoding.cpp

Issue 1407663004: Tweaking WebPageSerializerImpl to emit a BOM for UTF16/32. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Saving UTF16 with BOM. Leaving UTF32 in a broken state. Created 5 years 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/wtf/text/TextEncoding.cpp
diff --git a/third_party/WebKit/Source/wtf/text/TextEncoding.cpp b/third_party/WebKit/Source/wtf/text/TextEncoding.cpp
index 3b0563887861bc7145b7422c056fe2fc2fca2e15..76aa25a60bb7a718a1145ce0ad4022d60ed7e4f0 100644
--- a/third_party/WebKit/Source/wtf/text/TextEncoding.cpp
+++ b/third_party/WebKit/Source/wtf/text/TextEncoding.cpp
@@ -84,6 +84,18 @@ CString TextEncoding::encode(const String& string, UnencodableHandling handling)
return encodedString;
}
+CString TextEncoding::encodeBOMifApplicable() const
+{
+ // TODO(lukasza): Store |textCodec| in a member field, so it can be reused
+ // across repeated calls to encode and/or encodeBOMifApplicable.
jsbell 2015/12/07 22:53:51 That would change the behavior for stateful encodi
+ OwnPtr<TextCodec> textCodec = newTextCodec(*this);
+ if (!textCodec->shouldIncludeBOM())
+ return "";
+
+ const UChar bomCharacter = 0xFEFF;
+ return textCodec->encode(&bomCharacter, 1, QuestionMarksForUnencodables);
+}
+
bool TextEncoding::usesVisualOrdering() const
{
if (noExtendedTextEncodingNameUsed())

Powered by Google App Engine
This is Rietveld 408576698