]> git.tdb.fi Git - libs/core.git/blob - source/utf8.h
18f9ae58f93fa42421887422986e038c276e3abe
[libs/core.git] / source / utf8.h
1 #ifndef MSP_STRINGS_UTF8_H_
2 #define MSP_STRINGS_UTF8_H_
3
4 #include "codec.h"
5
6 namespace Msp {
7
8 class Utf8: public StringCodec
9 {
10 public:
11         class Encoder: public StringCodec::Encoder
12         {
13         public:
14                 void encode_char(wchar_t);
15         };
16
17         class Decoder: public StringCodec::Decoder
18         {
19         public:
20                 Decoder(): bytes(0), code(0) { }
21                 void     decode_char(const std::string &, std::string::const_iterator &);
22                 void     sync();
23         private:
24                 unsigned bytes;
25                 unsigned code;
26         };
27
28         Encoder *create_encoder() const { return new Encoder; }
29         Decoder *create_decoder() const { return new Decoder; }
30 };
31
32 } // namespace Msp
33
34 #endif