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

Unified Diff: Source/wtf/text/TextCodec.h

Issue 23532016: Handle odd data lengths in UTF-16 decoder (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Simplify 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
« no previous file with comments | « Source/modules/encoding/TextDecoder.cpp ('k') | Source/wtf/text/TextCodecICU.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/TextCodec.h
diff --git a/Source/wtf/text/TextCodec.h b/Source/wtf/text/TextCodec.h
index 259bc61e2d3218cb60a64e707791151e249c4f9e..dbfb6cb43d123980a2736a71556189cf34f1c055 100644
--- a/Source/wtf/text/TextCodec.h
+++ b/Source/wtf/text/TextCodec.h
@@ -56,19 +56,35 @@ enum UnencodableHandling {
typedef char UnencodableReplacementArray[32];
+enum FlushBehavior {
+ // More bytes are coming, don't flush the codec.
+ DoNotFlush = 0,
+
+ // A fetch has hit EOF. Some codecs handle fetches differently, for compat reasons.
+ FetchEOF,
+
+ // Do a full flush of the codec.
+ DataEOF
+};
+
+COMPILE_ASSERT(!DoNotFlush, DoNotFlush_is_falsy);
+COMPILE_ASSERT(FetchEOF, FetchEOF_is_truthy);
+COMPILE_ASSERT(DataEOF, DataEOF_is_truthy);
+
+
class TextCodec {
WTF_MAKE_NONCOPYABLE(TextCodec); WTF_MAKE_FAST_ALLOCATED;
public:
TextCodec() { }
virtual ~TextCodec();
- String decode(const char* str, size_t length, bool flush = false)
+ String decode(const char* str, size_t length, FlushBehavior flush = DoNotFlush)
{
bool ignored;
return decode(str, length, flush, false, ignored);
}
- virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError) = 0;
+ virtual String decode(const char*, size_t length, FlushBehavior, bool stopOnError, bool& sawError) = 0;
virtual CString encode(const UChar*, size_t length, UnencodableHandling) = 0;
virtual CString encode(const LChar*, size_t length, UnencodableHandling) = 0;
« no previous file with comments | « Source/modules/encoding/TextDecoder.cpp ('k') | Source/wtf/text/TextCodecICU.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698