summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/text/TextCodec.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/platform/text/TextCodec.h')
-rw-r--r--WebCore/platform/text/TextCodec.h39
1 files changed, 32 insertions, 7 deletions
diff --git a/WebCore/platform/text/TextCodec.h b/WebCore/platform/text/TextCodec.h
index 77ffcf4..0a56262 100644
--- a/WebCore/platform/text/TextCodec.h
+++ b/WebCore/platform/text/TextCodec.h
@@ -32,21 +32,46 @@
#include <wtf/Vector.h>
#include <wtf/unicode/Unicode.h>
-namespace WebCore {
+#include "PlatformString.h"
- class CString;
- class String;
+namespace WebCore {
class TextEncoding;
+ // Specifies what will happen when a character is encountered that is
+ // not encodable in the character set.
+ enum UnencodableHandling {
+ // Substitutes the replacement character "?".
+ QuestionMarksForUnencodables,
+
+ // Encodes the character as an XML entity. For example, U+06DE
+ // would be "&#1758;" (0x6DE = 1758 in octal).
+ EntitiesForUnencodables,
+
+ // Encodes the character as en entity as above, but escaped
+ // non-alphanumeric characters. This is used in URLs.
+ // For example, U+6DE would be "%26%231758%3B".
+ URLEncodedEntitiesForUnencodables,
+ };
+
+ typedef char UnencodableReplacementArray[32];
+
class TextCodec : Noncopyable {
public:
virtual ~TextCodec();
- virtual String decode(const char*, size_t length, bool flush = false) = 0;
- virtual CString encode(const UChar*, size_t length, bool allowEntities = false) = 0;
+ String decode(const char* str, size_t length, bool flush = false)
+ {
+ 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 CString encode(const UChar*, size_t length, UnencodableHandling) = 0;
- protected:
- static void appendOmittingBOM(Vector<UChar>&, const UChar*, size_t length);
+ // Fills a null-terminated string representation of the given
+ // unencodable character into the given replacement buffer.
+ // The length of the string (not including the null) will be returned.
+ static int getUnencodableReplacement(unsigned codePoint, UnencodableHandling, UnencodableReplacementArray);
};
typedef void (*EncodingNameRegistrar)(const char* alias, const char* name);