+/* $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_
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();
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