#ifndef TextEncoding_h
#define TextEncoding_h
#include "wtf/Forward.h"
#include "wtf/WTFExport.h"
#include "wtf/text/TextCodec.h"
#include "wtf/unicode/Unicode.h"
namespace WTF {
class WTF_EXPORT TextEncoding {
public:
TextEncoding() : m_name(0) { }
TextEncoding(const char* name);
TextEncoding(const String& name);
bool isValid() const { return m_name; }
const char* name() const { return m_name; }
bool usesVisualOrdering() const;
const TextEncoding& closestByteBasedEquivalent() const;
const TextEncoding& encodingForFormSubmission() const;
String decode(const char* str, size_t length) const
{
bool ignored;
return decode(str, length, false, ignored);
}
String decode(const char*, size_t length, bool stopOnError, bool& sawError) const;
CString encode(const String&, UnencodableHandling) const;
CString normalizeAndEncode(const String&, UnencodableHandling) const;
UChar backslashAsCurrencySymbol() const;
private:
bool isNonByteBasedEncoding() const;
bool isUTF7Encoding() const;
const char* m_name;
UChar m_backslashAsCurrencySymbol;
};
inline bool operator==(const TextEncoding& a, const TextEncoding& b) { return a.name() == b.name(); }
inline bool operator!=(const TextEncoding& a, const TextEncoding& b) { return a.name() != b.name(); }
WTF_EXPORT const TextEncoding& ASCIIEncoding();
WTF_EXPORT const TextEncoding& Latin1Encoding();
WTF_EXPORT const TextEncoding& UTF16BigEndianEncoding();
WTF_EXPORT const TextEncoding& UTF16LittleEndianEncoding();
WTF_EXPORT const TextEncoding& UTF32BigEndianEncoding();
WTF_EXPORT const TextEncoding& UTF32LittleEndianEncoding();
WTF_EXPORT const TextEncoding& UTF8Encoding();
WTF_EXPORT const TextEncoding& WindowsLatin1Encoding();
}
using WTF::ASCIIEncoding;
using WTF::Latin1Encoding;
using WTF::UTF16BigEndianEncoding;
using WTF::UTF16LittleEndianEncoding;
using WTF::UTF32BigEndianEncoding;
using WTF::UTF32LittleEndianEncoding;
using WTF::UTF8Encoding;
using WTF::WindowsLatin1Encoding;
#endif