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

Unified Diff: Source/wtf/text/TextCodecReplacement.cpp

Issue 145973021: Implement "replacement" text encoding. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Verify replacement name Created 6 years, 10 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/wtf/text/TextCodecReplacement.cpp
diff --git a/Source/wtf/text/TextCodecReplacement.cpp b/Source/wtf/text/TextCodecReplacement.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c9c229ca697b5ea2d09af85dddc49730f34ecf56
--- /dev/null
+++ b/Source/wtf/text/TextCodecReplacement.cpp
@@ -0,0 +1,44 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "wtf/text/TextCodecReplacement.h"
+
+#include "wtf/PassOwnPtr.h"
+#include "wtf/text/CString.h"
+#include "wtf/text/StringBuffer.h"
+#include "wtf/text/StringBuilder.h"
+#include "wtf/text/WTFString.h"
+
+namespace WTF {
+
+void TextCodecReplacement::registerEncodingNames(EncodingNameRegistrar registrar)
+{
+ // The "replacement" encoding should not be available by name directly,
+ // but is necessary during registration. It will be removed after the
+ // labels are registered.
+ registrar("replacement", "replacement");
+ registrar("csiso2022kr", "replacement");
+ registrar("iso-2022-cn", "replacement");
+ registrar("iso-2022-cn-ext", "replacement");
+ registrar("iso-2022-kr", "replacement");
+}
+
+static PassOwnPtr<TextCodec> newStreamingTextDecoderReplacement(const TextEncoding&, const void*)
+{
+ return adoptPtr(new TextCodecReplacement);
+}
+
+void TextCodecReplacement::registerCodecs(TextCodecRegistrar registrar)
+{
+ registrar("replacement", newStreamingTextDecoderReplacement, 0);
+}
+
+String TextCodecReplacement::decode(const char*, size_t, bool, bool, bool& sawError)
+{
+ sawError = true;
+ return String();
+}
+
+} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698