X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Futf8.h;h=94569eef9542f551ff8f821c5b6d079aa3f36325;hp=0475523cf52578216e9a63c4a4942ad1c18936e9;hb=9da6abdcabec59f4845da256a8ad75a810ed1589;hpb=51b84c0c2c3abb0cf7e815c5ae259face40ac977 diff --git a/source/utf8.h b/source/utf8.h index 0475523..94569ee 100644 --- a/source/utf8.h +++ b/source/utf8.h @@ -1,3 +1,10 @@ +/* $Id$ + +This file is part of libmspstrings +Copyright © 2006-2007 Mikko Rasa +Distributed under the LGPL +*/ + #ifndef MSP_STRINGS_UTF8_H_ #define MSP_STRINGS_UTF8_H_ @@ -11,13 +18,16 @@ public: class Encoder: public StringCodec::Encoder { public: + Encoder(ErrorMode em=THROW_ON_ERROR): StringCodec::Encoder(em) { } void encode_char(wchar_t); + private: + void append_replacement() { append("\357\277\275"); } }; class Decoder: public StringCodec::Decoder { public: - Decoder(): bytes(0), code(0) { } + Decoder(ErrorMode em=THROW_ON_ERROR): StringCodec::Decoder(em), bytes(0), code(0) { } void decode_char(const std::string &, std::string::const_iterator &); void sync(); void reset(); @@ -26,8 +36,8 @@ public: unsigned code; }; - Encoder *create_encoder() const { return new Encoder; } - Decoder *create_decoder() const { return new Decoder; } + Encoder *create_encoder(ErrorMode em=THROW_ON_ERROR) const { return new Encoder(em); } + Decoder *create_decoder(ErrorMode em=THROW_ON_ERROR) const { return new Decoder(em); } }; } // namespace Msp