1 #include "windows1252.h"
7 unsigned short table[32]=
9 0x20AC, 0, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
10 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0, 0x017D, 0,
11 0, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
12 0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0, 0x017E, 0x0178
19 namespace StringCodec {
21 void Windows1252::Encoder::encode_char(UnicodeChar ch, string &buf)
23 if((ch>=0 && ch<=0x7F) || (ch>=0xA0 && ch<=0xFF))
27 for(unsigned i=0; i<32; ++i)
34 error(ch, buf, "Can't express character in Windows-1252");
38 void Windows1252::Encoder::transliterate(UnicodeChar, string &buf)
44 UnicodeChar Windows1252::Decoder::decode_char(const string &str, string::const_iterator &i)
47 return error("No input");
49 int ch = static_cast<unsigned char>(*i);
51 if(ch>=0x80 && ch<=0x9F)
53 result = table[ch-0x80];
55 result = error("Undefined Windows-1252 character");
64 } // namespace StringCodec