X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fstringcodec%2Futf16.h;h=73d81cb9c26a15ec4ad9c318e4525f5a5a4a3705;hp=7fecf1efaad4ef7918da7b6ed8aa3f4122b69ef3;hb=HEAD;hpb=93e69e6635f5c47591f42b6979d4d1fce85846d4 diff --git a/source/stringcodec/utf16.h b/source/stringcodec/utf16.h index 7fecf1e..a588b12 100644 --- a/source/stringcodec/utf16.h +++ b/source/stringcodec/utf16.h @@ -1,6 +1,7 @@ #ifndef MSP_STRINGCODEC_UTF16_H_ #define MSP_STRINGCODEC_UTF16_H_ +#include #include "codec.h" namespace Msp { @@ -11,7 +12,7 @@ The UTF-16 codec, as specified in the Unicode standard. Both little and big endian are supported, as well as autodetection with the BOM. In the absence of a BOM, big endian is assumed. */ -class Utf16: public StandardCodec +class MSPCORE_API Utf16: public StandardCodec { public: enum Endian @@ -21,35 +22,35 @@ public: LITTLE }; - class Encoder: public Codec::Encoder + class MSPCORE_API Encoder: public Codec::Encoder { private: - Endian endian; - bool emit_bom; + Endian endian = BIG; + bool emit_bom = true; public: Encoder(ErrorMode em = DEFAULT, Endian en = BIG); - virtual void encode_char(unichar, std::string &); + void encode_char(unichar, std::string &) override; private: - virtual void transliterate(unichar, std::string &); + void transliterate(unichar, std::string &) override; }; - class Decoder: public Codec::Decoder + class MSPCORE_API Decoder: public Codec::Decoder { private: - Endian endian; + Endian endian = AUTO; public: Decoder(ErrorMode em = DEFAULT, Endian en = AUTO); - virtual unichar decode_char(const std::string &, std::string::const_iterator &); + unichar decode_char(const std::string &, std::string::const_iterator &) override; private: unichar decode_unit(const std::string &, const std::string::const_iterator &, std::string::const_iterator &); }; private: - Endian endian; + Endian endian = AUTO; public: Utf16(ErrorMode em = DEFAULT, Endian en = AUTO): @@ -57,13 +58,13 @@ public: endian(en) { } - virtual const char *get_name() const + const char *get_name() const override { return endian==BIG ? "UTF-16-BE" : endian==LITTLE ? "UTF-16-LE" : "UTF-16"; } - virtual Encoder *create_encoder(ErrorMode em = DEFAULT) const + Encoder *create_encoder(ErrorMode em = DEFAULT) const override { return new Encoder(get_error_mode(em), endian); } - virtual Decoder *create_decoder(ErrorMode em = DEFAULT) const + Decoder *create_decoder(ErrorMode em = DEFAULT) const override { return new Decoder(get_error_mode(em), endian); } };