]> git.tdb.fi Git - libs/core.git/blob - source/stringcodec/jisx0208.h
Additional adjustments for Poller
[libs/core.git] / source / stringcodec / jisx0208.h
1 #ifndef MSP_STRINGCODEC_JISX0208_H_
2 #define MSP_STRINGCODEC_JISX0208_H_
3
4 #include "codec.h"
5
6 namespace Msp {
7 namespace StringCodec {
8
9 /**
10 Codec for the JIS X 0208 encoding.  This is not particularly useful as a
11 stand-alone codec, due to lack of a linefeed character among other things,
12 but is included as part of some other encodings.
13 */
14 class JisX0208: public StandardCodec<JisX0208>
15 {
16 public:
17         class Encoder: public Codec::Encoder
18         {
19         public:
20                 Encoder(ErrorMode em = DEFAULT): Codec::Encoder(em) { }
21
22                 virtual void encode_char(unichar, std::string &);
23         private:
24                 virtual void transliterate(unichar, std::string &);
25         };
26
27         class Decoder: public Codec::Decoder
28         {
29         public:
30                 Decoder(ErrorMode em = DEFAULT): Codec::Decoder(em) { }
31
32                 virtual unichar decode_char(const std::string &, std::string::const_iterator &);
33         };
34
35         JisX0208(ErrorMode em = DEFAULT): StandardCodec<JisX0208>(em) { }
36
37         virtual const char *get_name() const { return "JIS X 0208"; }
38 };
39
40
41 struct Kuten
42 {
43         unsigned short ku;
44         unsigned short ten;
45
46         Kuten(): ku(0), ten(0) { }
47
48         operator bool() { return ku!=0 && ten!=0; }
49 };
50
51 unichar jisx0208_to_ucs(Kuten);
52 Kuten ucs_to_jisx0208(unichar);
53
54 } // namespace StringCodec
55 } // namespace Msp
56
57 #endif